For example, I saw source code like the following. Can we use #define
in a function? How does it work? (more information: this code is what I copied from
You can use #define
anywhere you want. It has no knowledge of functions and is not bound by their scope. As the preprocessor scans the file from top-to-bottom it processes #define
s as it sees them. Do not be misled (by silly code like this!) into thinking that the #define
is somehow processed only when the function is called; it's not.