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?
Yes.last
just replacing text
Performed by pre-processing. Some good details can be found here.
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.
#define
"" - " ".
" ", , .
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.
This is an instruction for the compiler and therefore is stored in tables in the compiler process space, and not in your code space.
Macros are just text replacements. When replaced, they become part of the code and therefore are stored in the CODE SEGMENT.