Using the same variable in different files (using extern)
This question already has an answer here:
The extern
keyword should be placed in the header file, and the variable definition need only be in one source file, so what you want is this:
In Ah:
extern uchar *const x;
extern uchar *const y;
In Ac
uchar *const x;
uchar *const y;
In Bc
#include "A.h"
void someFunction() {
foo(x);
bar(y);
}
In Cc
#include "A.h"
void someOtherFunction() {
foo(x);
bar(y);
}
链接地址: http://www.djcxy.com/p/40494.html
上一篇: 链接器错误与链接器无关