'obj_type'未在此范围中声明,注意:建议备选项:枚举Value_type [英] ‘obj_type’ was not declared in this scope, note: suggested alternative: enum Value_type

查看:486
本文介绍了'obj_type'未在此范围中声明,注意:建议备选项:枚举Value_type的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用JSON精灵来解析和生成json。



我不能使用使用命名空间json_spirit 另一个库使用冲突的名称。



我试图检测类型

  if(message.type()== obj_type)

 错误:'obj_type'未在此范围内声明
if(stamper_message.type()== obj_type) {
^
note:建议的替代方案:
在/usr/local/include/json_spirit.h:13:0中包含的文件中:
/ usr / local / include / json_spirit_value .h:32:22:note:'obj_type'
枚举Value_type {obj_type,array_type,str_type,bool_type,int_type,real_type,null_type};

我也添加了此行

 使用json_spirit :: Value_type; 

和此行

  typedef json_spirit :: Value_type Value_type; 

但不起作用。



我为这样一个简单的问题道歉,但我找不到一个解决方案,那么如何导入 enum 以使用这种方式?

解决方案

一个很老的问答

 使用json_spirit :: Value_type; 
Value_type obj_type = Value_type :: obj_type;

如果有人发布更好的东西或者在一行中声明所有枚举成员,我将删除。 / p>

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?

解决方案

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.

这篇关于'obj_type'未在此范围中声明,注意:建议备选项:枚举Value_type的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆