开发者

Storage size of 'var' isn't known

开发者 https://www.devze.com 2023-02-03 18:00 出处:网络
I have a program which works fine under VC++, but is giving me an error under GCC. within log.h: namespace logType {

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消