Closed wukefe closed 6 years ago
Filename: test_macro.cc
#include <stdio.h> #define max(a,b) ((a)>(b)?(a):(b)) #define MAX(a,b) ((a)>(b)?(a):(b)) #include <stdlib.h> int main(){ // test macro max/MAX printf("max(a,b)=%d\n",max(1,5)); printf("MAX(a,b)=%d\n",MAX(1,5)); return 0; }
Environment
max
If the line #include <stdlib.h> is moved upon the two macros, the compiler gcc-7 passes.
#include <stdlib.h>
gcc-7
So probably there is a following macro inside stdlib.h for the compiler g++.
stdlib.h
#ifdef max #undef max #endif
Input
Filename: test_macro.cc
Testing
Environment
max