Thread: Conditional Compilation

  1. #1
    Registered User
    Join Date
    Sep 2001
    Posts
    23

    Question Conditional Compilation

    I am not understanding the following textbook question:

    Suppose the following macro M is defined as such:

    #define M 10

    Which of the following tests will fail??

    (a) #if M
    (b) #ifdef M
    (c) #ifndef M
    (d) #if defined (M)
    (e) #if !defined (M)


    They are seem like they are valid to me.
    What I am I missing here??? maybe (c) and (e) aren't technically valid since M is defined???

    Help !!!!!!!!!!!!!

  2. #2
    Registered User
    Join Date
    Sep 2001
    Posts
    752
    They are all valid, but that's not what is meant by whether a test fails or not. Just pick the ones which will not evaluate TRUE, and you picked them... (c) and (e)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Conditional compilation for object files in Makefile?
    By jutirain in forum C++ Programming
    Replies: 13
    Last Post: 12-19-2007, 06:23 AM
  2. conditional compilation based on existance of a symbol?
    By cyberfish in forum C++ Programming
    Replies: 6
    Last Post: 12-13-2007, 07:35 PM
  3. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  4. conditional compilation
    By Garfield in forum C Programming
    Replies: 4
    Last Post: 10-21-2001, 09:08 AM
  5. Preproccessor conditional compilation
    By Garfield in forum C Programming
    Replies: 5
    Last Post: 09-28-2001, 09:28 AM