0

Is there any way to find out what is the value of #define Pre processor directive.

Example:

#define CONST 1
#if CONST
add(a,b);
#endif

Below are my questions.

  1. In the above code is there a way to find out what is the value of CONST in memory.
  2. Does CONST have a address where it is stored.
  3. Can we find out by looking into .map file and figure out the value of CONST.
  • If the domain of CONST must be an int, then you can declare an int variable and assign CONST to it. If it strays from an int then the compiler will complain. If the domain is highly flexible, then you can [stringify](https://stackoverflow.com/q/2653214/1707353) it and assign it to a `char *` variable so long as you're using gcc (maybe other tools support stringification of macro values). – Jeff Holt Apr 23 '20 at 19:06

1 Answers1

2

#defines does not have any memory address.

It's a preprocessor directive. It is resolved during the preprocessor phase, which comes before the compilation and linking. Therefore, you won't find it in the symbol table.

MrBens
  • 1,227
  • 1
  • 9
  • 19