什么是最短或最简单的方法来解决以下依赖性问题。鉴于此,我必须将xx
保留在单独的文件中。
file1.h
static inline void xx(){
yy();//yy is not defined in this file but defined in file2.c;
}
file2.c
#include "file1.h"
void yy(){
printf("Hello");
}
void main(){
xx();
}
未定义文件1中的编译器错误。
需要声明,但没有定义:
// file1.h
static inline void xx() {
void yy(); // Just a declaration
yy();
}
预声明yy
。
只需在使用函数之前声明就可以解决问题。