我只是在玩代码块并编写一个非常简单的程序,但我得到了未定义的引用错误......我将完全相同的代码复制到其他地方并在终端中编译它并且工作正常,但就是不起作用在代码块中。
我的 main.c 是:
#include <stdio.h>
#include "subfunc.h"
int main()
{
printhello();
return 0;
}
然后我的 subfunc.c 是:
#include <stdio.h>
#include "subfunc.h"
void printhello(void)
{
printf("hello world in function\n");
}
然后我的 subfunc.h 是:
void printhello(void);
谢谢
更新
其实..我想通了。我右键单击文件 subfunc.c 和 subfunc.h 并选择属性并转到构建选项卡,我发现编译文件和链接文件的选项没有勾选。谢谢