Where are macros stored?

If I use macros in my C code, for example

#define var 10

then where exactly are stored in the space allocated to the process by the core? In a heap or BSS or global data? Or is it just replacing the text for var in one of the compiler passes?

+5
source share
5 answers

Yes.
last

just replacing text

Performed by pre-processing. Some good details can be found here.

+14
source

Preprocessor directives, such as those #define, are replaced with the appropriate text during the compilation preprocessing phase and are (almost) never presented in the final executable.

+4
source

"" - " ".

" ", , .

The result (in compiled code) can be a set of operations ... a data declaration ... or nothing at all.

But the macro itself is an Ancient story after the completion of the preprocessor and before the compilation.

+3
source

This is an instruction for the compiler and therefore is stored in tables in the compiler process space, and not in your code space.

0
source

Macros are just text replacements. When replaced, they become part of the code and therefore are stored in the CODE SEGMENT.

0
source

All Articles