unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* GCC, Objective-C and C99
@ 2020-08-27 21:24 Alan Third
  2020-08-27 22:07 ` Paul Eggert
  0 siblings, 1 reply; 3+ messages in thread
From: Alan Third @ 2020-08-27 21:24 UTC (permalink / raw)
  To: Emacs-Devel devel

I've pushed a new test into scratch/ns-gitlab-ci that runs a build
against GNUstep on emba, however it's failing. I get this error:

nsterm.m: In function '-[EmacsView insertText:]':
nsterm.m:6636:3: error: 'for' loop initial declarations are only allowed in C99 or C11 mode
   for (NSUInteger i = 0; i < len; i++)
   ^~~

Now, as far as I can tell all I have to do is add -std=c99 when
compiling Objective C, but I'm really not sure where to add it. In a
test I added it to CFLAGS when I configured, and that worked, but that
doesn't seem like a proper fix.

What's really odd is that I never had this problem when I built on a
VM based off Debian Jessie, but I now do with the Debian Stretch
Docker image. I guess something's changed with GCC.
-- 
Alan Third



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: GCC, Objective-C and C99
  2020-08-27 21:24 GCC, Objective-C and C99 Alan Third
@ 2020-08-27 22:07 ` Paul Eggert
  2020-08-27 23:28   ` Alan Third
  0 siblings, 1 reply; 3+ messages in thread
From: Paul Eggert @ 2020-08-27 22:07 UTC (permalink / raw)
  To: Alan Third; +Cc: Emacs-Devel devel

On 8/27/20 2:24 PM, Alan Third wrote:
> What's really odd is that I never had this problem when I built on a
> VM based off Debian Jessie, but I now do with the Debian Stretch
> Docker image. I guess something's changed with GCC.

Perhaps the newer GCC no longer needs -std=c99 when compiling C files (so 
'configure' doesn't add the option automatically), but for some reason GCC still 
rejects declarations in for loops when compiling Objective C files unless you 
also specify -std=c99.

If this guess is correct, perhaps simply putting -std=c99 into the following 
line in configure.ac would work around this GCC glitch.

       ## Extra CFLAGS applied to src/*.m files.
       GNU_OBJC_CFLAGS="$GNU_OBJC_CFLAGS -fgnu-runtime -Wno-import 
-fconstant-string-class=NSConstantString -DGNUSTEP_BASE_LIBRARY=1 
-DGNU_GUI_LIBRARY=1 -DGNU_RUNTIME=1 -DGSWARN -DGSDIAGNOSE"



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: GCC, Objective-C and C99
  2020-08-27 22:07 ` Paul Eggert
@ 2020-08-27 23:28   ` Alan Third
  0 siblings, 0 replies; 3+ messages in thread
From: Alan Third @ 2020-08-27 23:28 UTC (permalink / raw)
  To: Paul Eggert; +Cc: Emacs-Devel devel

On Thu, Aug 27, 2020 at 03:07:25PM -0700, Paul Eggert wrote:
> On 8/27/20 2:24 PM, Alan Third wrote:
> > What's really odd is that I never had this problem when I built on a
> > VM based off Debian Jessie, but I now do with the Debian Stretch
> > Docker image. I guess something's changed with GCC.
> 
> Perhaps the newer GCC no longer needs -std=c99 when compiling C files (so
> 'configure' doesn't add the option automatically), but for some reason GCC
> still rejects declarations in for loops when compiling Objective C files
> unless you also specify -std=c99.
> 
> If this guess is correct, perhaps simply putting -std=c99 into the following
> line in configure.ac would work around this GCC glitch.
> 
>       ## Extra CFLAGS applied to src/*.m files.
>       GNU_OBJC_CFLAGS="$GNU_OBJC_CFLAGS -fgnu-runtime -Wno-import
> -fconstant-string-class=NSConstantString -DGNUSTEP_BASE_LIBRARY=1
> -DGNU_GUI_LIBRARY=1 -DGNU_RUNTIME=1 -DGSWARN -DGSDIAGNOSE"

I tried that (and I tried gnu99 too) but it made no difference:

https://emba.gnu.org/emacs/emacs/-/commit/445d18f97350d502067972d4291b9224b2f9d3c1

Oh wait, I think I see where that went wrong. That is only executed if
NS_GNUSTEP_CONFIG isn't set, which it probably will be. That part must
be a backup for if gnustep-config isn't usable.

I think I know what to do. Thanks!
-- 
Alan Third



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-08-27 23:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-08-27 21:24 GCC, Objective-C and C99 Alan Third
2020-08-27 22:07 ` Paul Eggert
2020-08-27 23:28   ` Alan Third

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).