3 ms·
Depends. What if someone wrote "#define if while" and the word "if" is a macro? // In #include<deep/deep/deep/include.h> #define if while // somew
by dragontamer 4y ago
Depends. What if someone wrote "#define if while" and the word "if" is a macro?
// In #include<deep/deep/deep/include.h>
#define if while
// somewhere else
if(1){
puts("Help, I'm stuck in an infinite loop!");
}
There's a reason why macros should be all-caps when used, and IMO, C++ programmers should prefer templates. Macros are too powerful, and need to be used extremely cautiously in my experience.
Pointing out that macros can totally mess up your expectations isn't exactly news to anybody who does C/C++ programming.
- bodhiandphysics 4y agoReally if I’m programming c++ I avoid macros (except if guards). Though I do have the advantage that my code doesn’t need to be portable