我向我的 Xcode 项目添加了两个文件(takeoff.h、takeoff.c),包括粘贴来自另一个项目的一些代码。现在,成功编译后,Xcode 似乎无法识别新文件。即使一切编译正常,来自 main.c 的调用也会被忽略。发生了什么事以及如何解决它?
// main.c
int main()
{
void test(void); // located in takeoff.c JUST IGNORED
}
//takeoff.c
void test(void)
{
print("Printed from takeoff.c"); // no printing nor do breakpoints stop her
{
最佳答案
更改为:
// main.c
void test(void); // <--- NB: function *prototype*
int main()
{
test(); // <--- NB: function *call*
}
和:
// takeoff.c
#include <stdio.h> // <--- NB: missing #include for printf
void test(void)
{
printf("Printed from takeoff.c\n"); // <--- NB: *printf*, not *print*
} // <--- NB: fixed closing brace
(更正标记为 <---
)
关于c - Xcode 无法识别文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6573682/