<分区>
Possible Duplicate:
Why does const imply internal linkage in C++, when it doesn’t in C?
What is external linkage and internal linkage in C++
我有两个 C 文件,我正在尝试将其编译为可执行文件。一个文件只包含一个声明如下(简化)。
const char *foo[2] = {"thing1", "thing2"};
第二个 c 文件做这个
extern const char *foo[2];
main()
{
//Code that does stuff with foo
}
编译时出现链接器错误,提示 foo 是未解析的外部符号。我假设编译器正在优化 foo。这里有什么想法吗?