这是一个示例代码,只是为了显示 LLVM 编译器和 GCC 的不同输出。我想知道为什么?答案应该很简单,但我看不到。(Xcode 4.6.1)
编码:
#include <stdio.h>
#define MAX(a,b) ( (a) > (b) ? (a) : (b) )
int increment() {
static int i = 42;
i += 5;
printf("increment returns %d\n",i);
return i;
}
int main( int argc, char ** argv ) {
int x = 50;
printf("max of %d and %d is %d\n", x,increment(),MAX(x, increment()));
printf("max of %d and %d is %d\n", x,increment(),MAX(x, increment()));
return 0;
}
LLVM 输出:
increment returns 47
increment returns 52
increment returns 57
max of 50 and 47 is 57
increment returns 62
increment returns 67
increment returns 72
max of 50 and 62 is 72
海合会输出:
increment returns 47
increment returns 52
max of 50 and 52 is 50
increment returns 57
increment returns 62
increment returns 67
max of 50 and 67 is 62