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

  2. c - "static const" vs "#define" vs "enum" - Stack Overflow

    Nov 4, 2009 · Which one is better to use among the below statements in C? static const int var = 5; or #define var 5 or enum { var = 5 };

  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?

    How can I use #if inside #define in the C preprocessor? Asked 15 years, 8 months ago Modified 10 months ago Viewed 51k times

  5. Good Programming Practices for Macro Definitions (#define) in C

    For example, never define a macro like this: #define DANGER 60 + 2 This can potentially be dangerous when we do an operation like this: int wrong_value = DANGER * 2; // Expecting 124 Instead, def...

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

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

  8. How do I define a function with optional arguments?

    How do I define a function with optional arguments? Asked 13 years, 11 months ago Modified 1 year, 7 months ago Viewed 1.2m times

  9. c - #Define VS Variable - Stack Overflow

    Jun 18, 2012 · #define WIDTH 10 is a preprocessor directive that allows you to specify a name (WIDTH) and its replacement text (10). The preprocessor parses the source file and each occurrence of the …

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

    Aug 24, 2010 · As the title says; what's the difference in practice between the inline keyword and the #define preprocessor directive?