About 50 results
Open links in new tab
  1. 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.

  2. 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 source code. …

  3. How can I define a define in C? - Stack Overflow

    The question is if users can define new macros in a macro, not if they can use macros in macros.

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

    I want to write a macro that spits out code based on the Boolean value of its parameter. So say DEF_CONST(true) should be expanded into const, and DEF_CONST(false) should be expanded …

  5. How do I show the value of a #define at compile-time?

    I know that this is a long time after the original query, but this may still be useful. This can be done in GCC using the stringify operator "#", but it requires two additional stages to be defined first. #define …

  6. 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?

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

    Aug 24, 2010 · 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 to ignore it. …

  8. #define macro for debug printing in C? - Stack Overflow

    #ifdef DEBUG #define DEBUG_TEST 1 #else #define DEBUG_TEST 0 #endif And then use DEBUG_TEST where I used DEBUG. If you insist on a string literal for the format string (probably a …

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

    As far as I know, what you're trying to do (use if statement and then return a value from a macro) isn't possible in ISO C... but it is somewhat possible with statement expressions (GNU extension). Since …

  10. c - Type of #define variables - Stack Overflow

    Dec 21, 2011 · If I have: #define MAXLINE 5000 What type is MAXLINE understood to be? Should I assume it is an int? Can I test it somehow? In general, how can one determine the type of #defineed …