Conditional Compilation

This is a discussion on Conditional Compilation within the C Programming forums, part of the General Programming Boards category; I am not understanding the following textbook question: Suppose the following macro M is defined as such: #define M 10 ...

  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, 05:23 AM
  2. conditional compilation based on existance of a symbol?
    By cyberfish in forum C++ Programming
    Replies: 6
    Last Post: 12-13-2007, 06: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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21