奇怪的编译器行为?这是一个错误.在Linux上使用GCC
#include <stdio.h>
#define NSIM 1
int main()
{
printf("%d\n\n",(2 +(NSIM==1)?0:99));
return 0;
}
Run Code Online (Sandbox Code Playgroud)
给出输出0(NSIM = 1)
但
#include <stdio.h>
#define NSIM 1
int main()
{
printf("%d\n\n",(2 +((NSIM==1)?0:99)));
return 0;
}
Run Code Online (Sandbox Code Playgroud)
给出了输出2
这是编译器中的一个错误 - 在我看来他们都应该给2