Can we have recursive macros?

Macros don’t directly expand recursively, but there are workarounds. When the preprocessor scans and expands pr(5): pr(5) ^ it creates a disabling context, so that when it sees pr again: ((5==1)? 1 : pr(5-1)) ^ it becomes painted blue, and can no longer expand, no matter what we try. But we can prevent our macro … Read more

DEBUG macros in C++

Is the second code snippet analogous to the one in C? More or less. It’s is more powerful, as you can include <<-separated values in the argument, so with a single argument you get something that would require a variable number of macro arguments in C. On the other hand, there is a slim chance … Read more

Why use #define instead of a variable

The #define is part of the preprocessor language for C and C++. When they’re used in code, the compiler just replaces the #define statement with what ever you want. For example, if you’re sick of writing for (int i=0; i<=10; i++) all the time, you can do the following: #define fori10 for (int i=0; i<=10; … Read more

Understanding the behavior of C’s preprocessor when a macro indirectly expands itself

Macro expansion is a complex process that is really only understandable by understanding the steps that occur. When a macro with arguments is recognized (macro name token followed by ( token), the following tokens up to the matching ) are scanned and split (on , tokens). No macro expansion happens while this is happening (so … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)