Is there a way, programatically, to tell if the compiler has been passed any one of --std-c89, --std-c99, --std-sdcc89 or --std-sdcc99, and to distinguish between them? Perhaps by a pre-defined symbol?
I had thought I should be able to use __STDC__ and __STDC_VERSION__ as follows for --std-c89 and--std-c99, but I don't seem to get sensible answers. __STDC__ is always defined (which is reasonable), but also __STDC_VERSION__ is always 199901L (implying C99).
To test this I placed the following in my code
#warning __STDC__ is defined (C89, and later)
#warning __STDC_VERSION__ is define (C90, and later)
#if __STDC_VERSION__ == 199409L
#warning __STDC_VERSION__ == 199409L (C94)
#if __STDC_VERSION__ == 199901L
#warning __STDC_VERSION__ == 199901L (C99)
I compile with...
$ sdcc-4491/bin/sdcc -c coreext.c -o coreext.rel
$ sdcc-4491/bin/sdcc -c --std-c89 coreext.c -o coreext.rel
$ sdcc-4491/bin/sdcc -c --std-c99 coreext.c -o coreext.rel
And I always get ...
coreext.c:36:2: warning: #warning __STDC__ is defined (C89, and later)
coreext.c:40:2: warning: #warning __STDC_VERSION__ is define (C90, and later)
coreext.c:47:2: warning: #warning __STDC_VERSION__ == 199901L (C99)
Am I simply misunderstaning the use of these pre-defined symbols?
Log in to post a comment.
Sign up for the SourceForge newsletter:
You seem to have CSS turned off.
Please don't fill out this field.