News:

When registered with our forums, feel free to send a "here I am" post here to differ human beings from SPAM bots.

Main Menu

Possible issue with GNU C flag option?

Started by ToApolytoXaos, October 20, 2013, 12:02:19 PM

Previous topic - Next topic

ToApolytoXaos

Guys, I'm experimenting with GNU C and seems I have an issue with defined(__GNUC__).

The code works, but the editor grays it for some reason.

See the build log please

Cheers.

P.S.: I forgot to mention, this is under GNU / Linux Debian testing (jessie) with the latest updates and gcc (Debian 4.8.1-10) 4.8.1.

Alpha

Settings->Editor->C/C++ Editor settings do you have 'Collect defines from project file' enabled?

ToApolytoXaos

#2
Quote from: Alpha on October 20, 2013, 03:46:52 PM
Settings->Editor->C/C++ Editor settings do you have 'Collect defines from project file' enabled?
Thanks Alpha, it was disabled. I enabled it and now works just fine :) thanks a million mate, much appreciated.

UPDATE: For those who are interested in such things, the following code works flawlessly on Linux with GCC, without involving any extra flag option added, whereas on Windows with MinGW, you have to add -std=gnu90 to make it work IF you have -ansi flag turned on; else you may remove both flags and still will compile just fine.

Here's the code:

Code (GNU C) Select

#include <stdio.h>

#if defined(__GNUC__) && defined(__STDC__) && __STDC__
__extension__
__inline__ void
demo() {
   int i;
   for (i = 0; i < 10; i++) {
       printf("[%d]: Demo!\n", i);
   }
}
#endif

int main(void)
{
   int i;
   for (i = 0; i < 10; i++) {
       printf("Executing the GNU C inlined function number #%d\n", i);
       demo();
   }
   return 0;
}


NOTE: On Windows this option is enabled by default, whereas on Linux it is not. Can we sync both versions' settings so they could behave if not alike, as closest as possible?