Pelles C forum

C language => Beginner questions => Topic started by: PhilG57 on April 09, 2026, 06:45:07 PM

Title: How to determine compiler standard
Post by: PhilG57 on April 09, 2026, 06:45:07 PM
Hi.  How can I, at compile time, determine and print the C standard the compiler is using.  I see __POCC__ to determine which version of Pelles IDE is being used, but not the C standard (11, 17, 22, etc.) with which my code is being compiled.  Thanks.
Title: Re: How to determine compiler standard
Post by: John Z on April 09, 2026, 06:58:56 PM
Hi Phil57,

Use the Menu: Project - Project Options, select Compiler in the tree view,  Now in that right side screen you will see 'C standard' and a drop down box.  The value in the box is the current C standard being used.

Use the 'C standard' drop down box to change to any other one you want.

'Project Options' is near the bottom of the Main Menu Project drop-down Menu btw.


John Z
Title: Re: How to determine compiler standard
Post by: Michele on April 09, 2026, 07:45:51 PM
If your scope is to use it in #if/#else#endif constructs to conditionally compile code based on the used standard you can use the symbols "__STDC_VERSION__  ", defined only when /Ze isn't used, or "__POCC_STDC_VERSION__" when /Ze is used.

From the help file:
Quote__STDC_VERSION__ Never defined when the /Ze option is used. The supported ISO C standard.
Defined as the integer constant 199901L when the /std=C99 option is used.
Defined as the integer constant 201112L when the /std=C11 option is used.
Defined as the integer constant 201710L when the /std=C17 option is used.
Defined as the integer constant 000000L (TBD) when the /std=C2X option is used. 
Title: Re: How to determine compiler standard
Post by: PhilG57 on April 10, 2026, 05:47:28 PM
Hey, many thanks.  The following seems to work great:
#if __POCC_STDC_VERSION__ == 199901
#pragma message("diff.c: Compiler standard is C99.")
#else
#if __POCC_STDC_VERSION__ == 201112
#pragma message("diff.c: Compiler standard is C11.")
#else
#if __POCC_STDC_VERSION__  == 201710
#pragma message("diff.c: Compiler standard is C17.")
#else
#pragma message("diff.c: Compiler standard is unknown.")
#endif
#endif
#endif

Of course, now I'm wondering if there is any way to get this information at run time...
Thanks again.