Knowing which standards are being used?
Is there a way to know what set of standards are being used for a specific compiler. I'm revamping one of my libraries and I would like to use const values in some of my methods, but I know that a lot of companies require code be C89 compatible, where there is no const. Is there some preprocessor definition that will allow me to do this on any compiler, or do I have to add a compiler option myself.
Code:
#ifdef C89_COMPATIBLE
#define _const
#else
#define _const const
#endif
void foo(_const char * str);
Is there a standard macro for that?
Re: Knowing which standards are being used?
Are you positive C89 does not support const? I know K&R C didn't, but this draft of the C standard from 1988 definitely mentions const and volatile:
http://flash-gordon.me.uk/ansi.c.txt
Re: Knowing which standards are being used?
I'm pretty sure C89 supports const. The Comeau online compiler in strict C89/90 mode doesn't complain about it.
As far as version, there's the macro __STDC_VERSION__, defined as 199901L for C99. I don't think it's present in C89/90 though.
Re: Knowing which standards are being used?
ninja9578, you may have missed my most recent reply to the thread Manipulating a character array, which you participated in.