How to properly use macros in C
pmihaylov.com
How to properly use macros in C
1–10 of 52 posts
Re: How to properly use macros in C
#2Re: How to properly use macros in C
#3Re: How to properly use macros in C
#4Calling all C preprocessor directives (like #include and #if) "macros" makes me skeptical. Is this usage common?
Re: How to properly use macros in C
#5Re: How to properly use macros in C
#6Re: How to properly use macros in C
#7Re: How to properly use macros in C
#8The claim that macros do not exist in other languages is incorrect. Every sensible assembly language compiler has macros to help the programmer with boilerplate.
The claim that multiline macros are a problem is correct. Suggesting that a workaround is to use a naming convention for such macros is crazy-talk. There is a time-honored pattern you use to fix this in the macro itself: wrap the macro with "do { } while (0)".
Re: How to properly use macros in C
#9 One strange phenomenon when coding in C is using macros. This is not something which can be seen in other programming languages (other than C++).
This is false. Lisp is a language, or rather, a family of languages, where macros play a giant role, and the author does not seem to mention them.But again, Lisps generally have more powerful macros than C does - they allow for arbitrary compile-time computation.
Re: How to properly use macros in C
#10Calling all C preprocessor directives (like #include and #if) "macros" makes me skeptical. Is this usage common?