為什么運(yùn)行失敗
為什么運(yùn)行失?。壳蟠笊裰笇?dǎo)。
#include <stdio.h>
#include "test.c"? ?//引用test.c文件
extern void printLine()? ? ?
{
? ?printf("**************\n");? ?
}
int main()
{
? ? say();
? ? return 0;
}
為什么運(yùn)行失?。壳蟠笊裰笇?dǎo)。
#include <stdio.h>
#include "test.c"? ?//引用test.c文件
extern void printLine()? ? ?
{
? ?printf("**************\n");? ?
}
int main()
{
? ? say();
? ? return 0;
}
2018-12-15
舉報(bào)
2018-12-17
這個(gè)是hello.c中的代碼,另外在test.c中 void say() 默認(rèn)是外部函數(shù),但是在hello.c中第二行又引用了test.c其實(shí)是沒(méi)必要的。說(shuō)白了就是人家本來(lái)就是外部函數(shù)可以直接調(diào)用但是你又引用了他的文件。
兩種可以方法解決:
hello.c中把第二行引用test.c注釋掉;
test.c中把void say()定義為內(nèi)部函數(shù)即static?void say() 。
問(wèn)題倒可以解決,但是并不確定也不明白為什么外部函數(shù)和引用文件會(huì)有沖突,可能跟編譯器有關(guān)吧。?
2018-12-15