Where does predefined macros reside in C?

341 Views Asked by At

I wonder where are predefined macros are defined and resided in?

Predefined macros are defined in compiler or preprocessor which has a dictionary that hold the pre-defined macros in the source code.

I mean __FILE__ macro has a definition and equivalence value in the compiler and the definition has been made in the compiler is it true?

1

There are 1 best solutions below

2
On

The C Preprocessor, For GCC Version 9.2.0, Chapter 3.7 (Predefined Macros) says:

Several object-like macros are predefined; you use them without supplying their definitions.

and later, for example

__LINE__ -- This macro expands to the current input line number, in the form of a decimal integer constant. While we call it a predefined macro, it’s a pretty strange macro, since its “definition” changes with each new line of source code


Meaning that there are no concrete definitions of these macros anywhere. During preprocessing time, the C preprocessor keeps track of which file it is currently processing and replaces __FILE__, __LINE__ and other "special" macros accordingly.