What error is thrown when macro and function conflict in C arises?
Is it a macro processor error or does this error occur due to some language violation?
For example, in this code:
#include <stdio.h>
#define MAX(i, j) (i>j)? i : j
int MAX(int i, int j){
return (i>j) ? i : j;
}
int main(){
int max = MAX(5, 7);
printf("%d",max);
return 0;
}
The program throws a compile time error. But I don’t understand whether it was some language violation or macro expansion error or something else.
During the preprocessing phase the code gets converted to :
…which, as anyone can tell, is an illegal C code.
(With
gccyou could use an-Eoption to see the preprocessed version of the file.)