-
August 3rd, 2010, 03:32 PM
#1
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?
-
August 3rd, 2010, 03:41 PM
#2
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
-
August 3rd, 2010, 10:19 PM
#3
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.
-
August 3rd, 2010, 11:08 PM
#4
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|