為什么運行失敗
為什么運行失敗?求大神指導。
#include <stdio.h>
#include "test.c"? ?//引用test.c文件
extern void printLine()? ? ?
{
? ?printf("**************\n");? ?
}
int main()
{
? ? say();
? ? return 0;
}
為什么運行失敗?求大神指導。
#include <stdio.h>
#include "test.c"? ?//引用test.c文件
extern void printLine()? ? ?
{
? ?printf("**************\n");? ?
}
int main()
{
? ? say();
? ? return 0;
}
2018-12-15
舉報
2018-12-17
這個是hello.c中的代碼,另外在test.c中 void say() 默認是外部函數,但是在hello.c中第二行又引用了test.c其實是沒必要的。說白了就是人家本來就是外部函數可以直接調用但是你又引用了他的文件。
兩種可以方法解決:
hello.c中把第二行引用test.c注釋掉;
test.c中把void say()定義為內部函數即static?void say() 。
問題倒可以解決,但是并不確定也不明白為什么外部函數和引用文件會有沖突,可能跟編譯器有關吧。?
2018-12-15