是否有可能让程序参数在xcode中工作?我正在为大学工作,并希望在xcode中使用调试器来帮助我了解最新情况。
我知道代码是最小的可编译的,因为我能够用gcc编译它,但是xcode无法识别语法。
我试图在xcode中运行的代码是:
#include <stdlib.h>
#include <stdio.h>
int main() {
int a = 50;
int b = 100;
void P(int *c, void R(int)) {
void Q(int p) {
printf("%d\n", p);
R(p+100);
}
if (a == b) R(b);
else {c = c + 25;
P(c, Q);
}
}
void Q(int p) {
printf("%d\n", p);
}
P(&a,Q);
}
答案 0 :(得分:1)
Xcode默认使用clang
编译器,does not support nested functions。要在Xcode中使用gcc
,请转到项目设置,选择目标并将编译器for C / C ++ / Objective-C 更改为LLVM GCC 4.2
。现在,如果你编译,gcc
会抱怨,嵌套函数没有启用。返回目标设置, LLVM GCC 4.2语言,并在其他C标志下添加-fnested-functions
。你的项目现在应该编译。