-1
假设我在我的项目中声明了以下头文件和.c文件。想象一下Type是我声明的一种数据类型。extern是否需要在另一个文件中定义的函数?
//header1.h
typedef struct Typing {
int size;
} Type;
Type foo(int);
int randomNum;
这里是.c文件
//header1.c
#include "header1.h"
Type foo(int size) {
Type type;
type.size = 100;
return type;
}
比方说有一个需要调用从头部这个函数foo其他一些文件名为example.h文件。如果我为函数或变量添加工作外部函数,这有什么关系吗?从我听到的情况来看,变量需要它。
//example.h
#include "header1.h"
extern int randomNum;
extern Type foo(int);
@Moderators:你不应该删除这里的冗长讨论。 – zwol