Thread: ansi C question

  1. #1
    Registered User moi's Avatar
    Join Date
    Jul 2002
    Posts
    946

    ansi C question

    is there any #define that can be checked to see if your source file is being compiled in an ansi-compliant enviornment?
    hello, internet!

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    There's a macro called __STDC__ which you can check. If the compiler supports standard C then __STDC__ will be defined as one, otherwise it will be undefined.

    Try running this. In MSVC++ 6 if you run the program with the /Za switch active then it will output 'Standard!' and if you turn off the /Za switch it will print 'Bugger!':
    Code:
    #include <stdio.h>
    
    int main ( void )
    {
    #ifdef __STDC__
      (void)puts ( "Standard!" );
    #else
      (void)puts ( "Bugger!" );
    #endif
      return 0;
    }
    -Prelude
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. another do while question
    By kbpsu in forum C++ Programming
    Replies: 3
    Last Post: 03-23-2009, 12:14 PM
  2. sigaction() and ANSI C
    By awoodland in forum Linux Programming
    Replies: 4
    Last Post: 04-25-2004, 01:48 AM
  3. Question...
    By TechWins in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 07-28-2003, 09:47 PM
  4. opengl DC question
    By SAMSAM in forum Game Programming
    Replies: 6
    Last Post: 02-26-2003, 09:22 PM
  5. just a quick clear screen question...
    By bobthefish3 in forum C Programming
    Replies: 6
    Last Post: 12-17-2001, 02:51 PM