‘obj_type’ was not declared in this scope, note: suggested alternative: enum Value_type

大兔子大兔子 提交于 2019-12-11 08:19:19

问题


I'm using JSON Spirit to parse and generate json.

I cannot use using namespace json_spirit because another library uses conflicting names.

I'm trying to detect the type as specified here of a read message with

if(message.type() == obj_type)

but the compiler reports

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 };

I have also added this line

using json_spirit::Value_type;

and this line

typedef json_spirit::Value_type Value_type;

but it doesn't help.

I apologize for such a simple question, but I cannot find a solution, so how can this enum be imported for use in this way?


回答1:


From a very old Q&A:

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

I will delete if someone posts something better or a way to declare all enum members in one line.



来源:https://stackoverflow.com/questions/21992445/obj-type-was-not-declared-in-this-scope-note-suggested-alternative-enum-val

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!