1

我正在使用 JSON Spirit 来解析和生成 json。

我不能使用using namespace json_spirit,因为另一个库使用冲突的名称。

我正在尝试检测此处指定的已读消息的类型

if(message.type() == obj_type)

但编译器报告

error: ‘obj_type’ was not declared in this scope
       if(stamper_message.type() == obj_type){
                                    ^
note: suggested alternative:
In file included from /usr/local/include/json_spirit.h:13:0:
/usr/local/include/json_spirit_value.h:32:22: note:   ‘obj_type’
     enum Value_type{ obj_type, array_type, str_type, bool_type, int_type, real_type, null_type };

我也添加了这一行

using json_spirit::Value_type;

这条线

typedef json_spirit::Value_type Value_type;

但这无济于事。

对于这样一个简单的问题,我深表歉意,但我找不到解决方案,那么如何将enum其导入以供以这种方式使用?

4

1 回答 1

1

来自一个非常古老的问答

using json_spirit::Value_type;
Value_type obj_type = Value_type::obj_type;

如果有人发布更好的内容或在一行中声明所有枚举成员的方式,我将删除。

于 2014-02-24T16:09:38.647 回答