為什么在test.c中,要將整個函數設定為static,而不能只將printLine設定為static
#include <stdio.h>
static void say(){
??? printLine();
??? printf("I love imooc\n");
??? printf("good good study!\n");
??? printf("day day up!\n");
??? printLine();
}
#include <stdio.h>
static void say(){
??? printLine();
??? printf("I love imooc\n");
??? printf("good good study!\n");
??? printf("day day up!\n");
??? printLine();
}
2020-06-26
舉報
2020-06-26
test.c中是say()函數的具體說明與實現;hello.c中的main函數中有內部函數也是say()函數,而hello.c的頭文件中已經包含了"test.c",這樣會讓編譯器認為say()函數定義了兩次,所以,只能在test.c中定義say()函數為static,說明此函數作用域只在test.c中使用。