About 7,620,000 results
Open links in new tab
  1. c++ - What does ## in a #define mean? - Stack Overflow

    In other words, when the compiler starts building your code, no #define statements or anything like that is left. A good way to understand what the preprocessor does to your code is to get …

  2. c++ - Why use #define instead of a variable - Stack Overflow

    May 14, 2011 · What is the point of #define in C++? I've only seen examples where it's used in place of a "magic number" but I don't see the point in just giving that value to a variable instead.

  3. How can I use #if inside #define in the C preprocessor?

    Just do something like this: #ifdef USE_CONST #define MYCONST const #else #define MYCONST #endif Then you can write code like this: MYCONST int x = 1; MYCONST char* …

  4. Is it possible to use a if statement inside #define?

    The \ at the end of each line is to signal line continuation (i.e. to tell the compiler "this macro continues on the next line") The ( { is a statement expression (GNU extension; not part of …

  5. What is the difference between #define and const? [duplicate]

    The #define directive is a preprocessor directive; the preprocessor replaces those macros by their body before the compiler even sees it. Think of it as an automatic search and replace of your …

  6. Defining and using a variable in batch file - Stack Overflow

    The space before the = is interpreted as part of the name, and the space after it (as well as the quotation marks) are interpreted as part of the value. So the variable you’ve created can be …

  7. What's the difference in practice between inline and #define?

    Nov 27, 2015 · 2 Macros (created with #define) are always replaced as written, and can have double-evaluation problems. inline on the other hand, is purely advisory - the compiler is free …

  8. Why do most C developers use define instead of const?

    Mar 4, 2017 · #define simply substitutes a name with its value. Furthermore, a #define 'd constant may be used in the preprocessor: you can use it with #ifdef to do conditional compilation …

  9. c++ - 'static const' vs. '#define' - Stack Overflow

    Oct 28, 2009 · Is it better to use static const variables than #define preprocessor? Or does it maybe depend on the context? What are advantages/disadvantages for each method?

  10. Why are #ifndef and #define used in C++ header files?

    I have been seeing code like this usually in the start of header files: #ifndef HEADERFILE_H #define HEADERFILE_H And at the end of the file is #endif What is the purpose of this?