What is the diff between if and #if?

This is a discussion on What is the diff between if and #if? within the C Programming forums, part of the General Programming Boards category; Can anyone expalin to me better "What is the diff between if and #if?" I thought i read that maybe ...

  1. #1
    TransparentMember correlcj's Avatar
    Join Date
    Jun 2002
    Posts
    378

    Question What is the diff between if and #if?

    Can anyone expalin to me better "What is the diff between if and #if?" I thought i read that maybe its because #if can only be used with constant conditions, is that correct. Someone told me that #if is faster and improves program readability than if does but connot be nested, is that true?
    Some please enlighten me?

  2. #2
    moi
    moi is offline
    Registered User moi's Avatar
    Join Date
    Jul 2002
    Posts
    946
    if is a part of the c language. #if is a part of the c preprocessor language.

    i've noticed a pattern of you starting threads asking the difference between things that aren't very related to eachother.
    hello, internet!

  3. #3
    TransparentMember correlcj's Avatar
    Join Date
    Jun 2002
    Posts
    378
    i've noticed a pattern of you starting threads asking the difference between things that aren't very related to eachother
    Just curoius MOI, remember, just curoius is all!
    Thanks for your input!

  4. #4
    aurė entuluva! mithrandir's Avatar
    Join Date
    Aug 2001
    Posts
    1,209
    #if is what we call a preprocessor directive...for more information try here.

    if is simply a C/C++ (and Java) keyword - a reserved word in the C language that cannot be used as a variable name. Your compiler recognises if as a conditional statement.

    >> I thought i read that maybe its because #if can only be used with constant conditions, is that correct<<

    Yes, that is correct.

  5. #5
    Visionary Philosopher Sayeh's Avatar
    Join Date
    Aug 2002
    Posts
    212
    Can anyone expalin to me better "What is the diff between if and #if?"
    "if" is a statement-- part of the defined c language. "#if" is also called a compiler directive -- it is used not for code, but to tell the compiler to do something during compilation.
    It is not the spoon that bends, it is you who bends around the spoon.

  6. #6
    TransparentMember correlcj's Avatar
    Join Date
    Jun 2002
    Posts
    378

    Whats Up!

    It is not the spoon that bends, it is you who bends around the spoon.
    -The Matrix.
    Cool Movie, i can't wait until numero dos.

Popular pages Recent additions subscribe to a feed

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