為什么第三行的代碼要用 static 而不是 extern ?
#include <stdio.h>
extern void printLine();
static void say()
{
? ? printLine();
? ? printf("I love imooc\n");
? ? printf("good good study!\n");
? ? printf("day day up!\n");
? ? printLine();
}
#include <stdio.h>
extern void printLine();
static void say()
{
? ? printLine();
? ? printf("I love imooc\n");
? ? printf("good good study!\n");
? ? printf("day day up!\n");
? ? printLine();
}
2021-03-07
舉報
2021-10-22
因為第三行是內(nèi)部的 外部是*
2021-03-09
本人新手,目前是這樣理解的,要是不對望大神指點
#include?"test.c"???//引用test.c文件----#include的作用純粹就是內(nèi)容拷貝,運行時被包含文件test.c中的文本將替換源代碼文件中的#include 指令;用extern定義say()函數(shù),程序運行時相當于hello.c與test.c中都定義了外部函數(shù)say(),而C語言規(guī)定不允許有同名的外部函數(shù),所以編譯會報錯。
不使用#include?"test.c"時則需用extern定義say()函數(shù):
hello.c
test.c