C++:枚举:错误:应使用标识符而不是"}"
C++: Enum: Error: Identifier expected instead of "}"
在 Solaris 11 x86 平台中从 openjdk 构建 jdk8u。收到警告:枚举中应使用标识符而不是"}"错误。通常,当我们在枚举末尾有逗号时,会抛出这种类型的错误。但在这种情况下,也没有额外的逗号。谁能指出问题出在哪里? 宏.hpp:
#ifndef INCLUDE_JFR
#define INCLUDE_JFR 1
#endif
#if INCLUDE_JFR
#define JFR_ONLY(code) code
#else
#define JFR_ONLY(code)
#endif
thread.hpp:
enum SuspendFlags {
// NOTE: avoid using the sign-bit as cc generates different test code
// when the sign-bit is used, and sometimes incorrectly - see CR 6398077
_external_suspend = 0x20000000U, // thread is asked to self suspend
_ext_suspended = 0x40000000U, // thread has self-suspended
_deopt_suspend = 0x10000000U, // thread needs to self suspend for deopt
_has_async_exception = 0x00000001U, // there is a pending async exception
_critical_native_unlock = 0x00000002U, // Must call back to unlock JNI critical lock
JFR_ONLY(_trace_flag = 0x00000004U) // call jfr tracing
};
错误:
Compiling /export/home/preethi/openjdk8u/hotspot/src/share/vm/compiler/abstractCompiler.cpp
Compiling /export/home/preethi/openjdk8u/hotspot/src/share/vm/utilities/accessFlags.cpp
Compiling ../generated/adfiles/ad_x86_32.cpp
"/export/home/preethi/openjdk8u/hotspot/src/share/vm/runtime/thread.hpp", line 202: Warning: Identifier expected instead of "}".
1 Warning(s) detected.
gmake[6]: *** [/export/home/preethi/openjdk8u/hotspot/make/solaris/makefiles/rules.make:148: accessFlags.o] Error 2
gmake[6]: *** Waiting for unfinished jobs....
"/export/home/preethi/openjdk8u/hotspot/src/share/vm/runtime/thread.hpp", line 202: Warning: Identifier expected instead of "}".
1 Warning(s) detected.
gmake[6]: *** [/export/home/preethi/openjdk8u/hotspot/make/solaris/makefiles/rules.make:148: abstractCompiler.o] Error 2
"/export/home/preethi/openjdk8u/hotspot/src/share/vm/runtime/thread.hpp", line 202: Warning: Identifier expected instead of "}".
1 Warning(s) detected.
gmake[6]: *** [/export/home/preethi/openjdk8u/hotspot/make/solaris/makefiles/rules.make:148: ad_x86_32.o] Error 2
gmake[5]: *** [/export/home/preethi/openjdk8u/hotspot/make/solaris/makefiles/top.make:112: the_vm] Error 2
gmake[4]: *** [/export/home/preethi/openjdk8u/hotspot/make/solaris/Makefile:226: product] Error 2
gmake[3]: *** [Makefile:231: generic_build2] Error 2
gmake[2]: *** [Makefile:177: product] Error 2
gmake[1]: *** [HotspotWrapper.gmk:45: /export/home/preethi/openjdk8u/build/solaris-x86-normal-server-release/hotspot/_hotspot.timestamp] Error 2
gmake: *** [/export/home/preethi/openjdk8u//make/Main.gmk:110: hotspot-only] Error 2
规则制作:
%.o: %.cpp
@echo Compiling $<
$(QUIETLY) $(REMOVE_TARGET)
$(QUIETLY) $(if $(findstring $@, $(NONPIC_OBJ_FILES)),
$(subst $(VM_PICFLAG), ,$(COMPILE.CXX)) $(DEPFLAGS) -o $@ $< $(COMPILE_DONE),
$(COMPILE.CXX) $(DEPFLAGS) -o $@ $< $(COMPILE_DONE))
提前感谢!
我认为将枚举元素作为定义的条件的想法不容易维护。
如果你不能摆脱宏,你可以试试这个(谢谢@Mestkon(:
#define COMMA ,
enum SuspendFlags {
// NOTE: avoid using the sign-bit as cc generates different test code
// when the sign-bit is used, and sometimes incorrectly - see CR 6398077
_external_suspend = 0x20000000U, // thread is asked to self suspend
_ext_suspended = 0x40000000U, // thread has self-suspended
_deopt_suspend = 0x10000000U, // thread needs to self suspend for deopt
_has_async_exception = 0x00000001U, // there is a pending async exception
_critical_native_unlock = 0x00000002U // (Removed end comma) Must call back to unlock JNI critical lock
JFR_ONLY(COMMA _trace_flag = 0x00000004U) // call jfr tracing
};
谢谢。我面临的问题是从openjdk构建jdk8u时。在配置中,我给出了--enable-jfr=yes,解决了我的问题。
相关文章:
- 不带大括号的枚举形式
- 枚举环境变量的惯用C++14/C++17方法
- 类似枚举的计算常量
- 如何正确实现和访问运算符的各种自定义枚举器
- 错误:从"int"到枚举c++的转换无效
- C++中构造函数中的枚举
- 访问在 C++ 结构中声明的枚举变量
- 枚举类'classname'的多重定义
- 强枚举类型定义:Clang Bug 还是 C++11 标准不确定性?
- typedef 枚举和枚举类有什么区别?
- 为什么我的开关/机箱在使用枚举时默认?
- C++:枚举:错误:应使用标识符而不是"}"
- 当枚举器列表项的标识符已是结构的成员时,如何使用枚举器列表项
- 使用标识符前缀访问枚举
- 声明枚举标识符的基础类型
- 有没有一种方法可以在枚举中使用关键字作为标识符
- 不同文件中同一命名空间中的 2 个不同枚举中的相同标识符
- 我可以使用枚举器的标识符拆除枚举器吗?
- 用带有 int 标识符的类替换枚举 - 不编译
- 在使用特定枚举标识符时打印出静态"deprecate"警告消息并附上建议的更正?