Storage size of 'var' isn't known
I have a program which works fine under VC++, but is giving me an error under GCC.
within log.h:
namespace logType {
enum Enum {
None = 0,
Info,
Warning,
Error,
};
std::string Name[];
}
within log.cpp:
std::string logType::Nam开发者_运维百科e[] = { "None", "Info", "WARNING", "ERROR" };
This works fine when I compile log.cpp. However, if any other file includes log.h, that file errors out:
error: storage size of ‘logType::Name’ isn't known
I've tried specifying the array size for Name[] in one or both of the files, but that just changes the error to that of redeclaration.
How do I get this to cooperate under GCC?
Add extern to log.h's declaration of your Name. Your symbol appears in two places.
加载中,请稍侯......
精彩评论