• 0 Posts
  • 3 Comments
Joined 7 months ago
cake
Cake day: February 26th, 2024

help-circle

  • I’m going to take a shot at answering this, but please bear in mind that it’s been a long time since I looked into the C pre-parser.

    #if allows for arbitrary Boolean logic, eg #if build_env “local”

    #if defined us to see if a thing has been defined already, quite often used to make sure that a header file is only imported once, redeclaration of headers is a compiler error. Eg. #if !defined(__SOME_UNIQUE_FILE_IDENTIFIER) (then define the class) then write your #endif

    #ifdef wasn’t always standard and was added later in the ANSI spec be a keyword, it’s shorthand for the same thing as #if defined. -

    This is my understanding anyway, I’m going with the principal that someone who knows more will be more likely to post a rebuttal (which I encourage).