Reputation:
actually i have a code which has macros serially
what i want to know here is how does they really work on the code because i want to write my own pre processor by seeing the below results im really surprised
#define int char //macro1
#define char float //macro2
#define float int //macro3
main()
{
int x;
char y;
float z;
}
what i expected the code to be in the file after pre processing is all three variables x,y,z as int,int,int
but surprising(to me) the types are unchanged why so? could any one explain me in detail how does the macros come in to play during pre processing
Upvotes: 0
Views: 79
Reputation: 70372
Macro expansion continues until expansion is completed, and macros cannot be recursively expanded. Each macro you defined expands to another macro, but stops when the expansion would become recursive, which means the types remain unchanged.
Upvotes: 4