Author Topic: Possible issue with GNU C flag option?  (Read 10011 times)

ToApolytoXaos

  • Guest
Possible issue with GNU C flag option?
« on: October 20, 2013, 12:02:19 pm »
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.
« Last Edit: October 24, 2013, 07:29:52 am by ToApolytoXaos »

Offline Alpha

  • Developer
  • Lives here!
  • *****
  • Posts: 1513
Re: Possible issue with GNU C flag option?
« Reply #1 on: October 20, 2013, 03:46:52 pm »
Settings->Editor->C/C++ Editor settings do you have 'Collect defines from project file' enabled?

ToApolytoXaos

  • Guest
Re: Possible issue with GNU C flag option?
« Reply #2 on: October 20, 2013, 11:32:50 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
#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?
« Last Edit: October 24, 2013, 07:29:10 am by ToApolytoXaos »