Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22148

How C preprocessor works?

$
0
0

How does the C Preprocessor handle multiple macros? I searched it over here and Google too but not able to understand the exact rule that should be followed. The following code:

#define ABC xYz
#define xYz ABC
int main()
{
    int ABC;
    int xYz;    
}

on gcc, generates preprocessor.i like this:

# 1 "preprocessor.c"
# 1 "<command-line>"
# 1 "preprocessor.c"


int main()
{
 int ABC;
 int xYz;
}

seems nothing is replaced here. And other code:

#define ABC kkk
#define xYz ABC
int main()
{
    int ABC;
    int xYz;    
}

generates output like this:

# 1 "preprocessor.c"
# 1 "<command-line>"
# 1 "preprocessor.c"


int main()
{
 int kkk;
 int kkk;
}

So how all these are happening.


Viewing all articles
Browse latest Browse all 22148

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>