Knowing which standards are being used?
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums
Results 1 to 4 of 4

Thread: Knowing which standards are being used?

  1. #1
    Join Date
    Jan 2009

    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.

    #ifdef C89_COMPATIBLE
       #define _const
       #define _const const
    void foo(_const char * str);
    Is there a standard macro for that?

  2. #2
    Lindley is offline Elite Member Power Poster
    Join Date
    Oct 2007
    Seattle, WA

    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:

  3. #3
    Join Date
    Aug 2007

    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.

  4. #4
    Join Date
    Jan 2006

    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.
    C + C++ Compiler: MinGW port of GCC
    Build + Version Control System: SCons + Bazaar

    Look up a C/C++ Reference and learn How To Ask Questions The Smart Way
    Kindly rate my posts if you found them useful

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)