我有一个带有以下代码的标头,该标头具有源自头文件 /usr/include/sys/param.h 中 CROUND 定义的神秘错误,该错误未包含在代码本身或通过命令行参数中:
#ifndef _PARSERTYPES_H_
#define _PARSERTYPES_H_
#ifdef CROUND
#warning #undef CROUND applied, defined in /usr/include/sys/param.h
#undef CROUND
#endif // CROUND
enum TokType
{
FLOATING, INTEGER, STRING, SYMBOL,
OCURLY, CCURLY, OROUND, CROUND, OSQUARE, CSQUARE,
};
#endif // _PARSERTYPES_H_
使用简化的 clang (c++) 或 gcc (g++) 编译器命令编译:
cd /path/to/build3/modules/device/examples/sweep && /usr/bin/g++ -DQT_OPENGL_LIB -DQT_DESIGNER_LIB -DQT_GUI_LIB -DQT_SQL_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -D__DC1394__ - -DQT_NO_DEBUG -O3 -DNDEBUG -I/path/to/modules//. -I/opt/local/include -I/opt/local/include/opencv -I/usr/local/include -I/opt/local/include/QtOpenGL -I/opt/local/include/QtDesigner -I/opt/local/include/QtGui -I/opt/local/include/QtSql -I/opt/local/include/QtNetwork -I/opt/local/include/QtCore -I/Library/Frameworks/FreeType.framework/Headers -F/Library/Frameworks -I/opt/local/include/glib-2.0 -I/opt/local/lib/glib-2.0/include -I/opt/local/include/gdk-pixbuf-2.0 -I/opt/local/include/gtk-2.0 -I/opt/local/lib/gtk-2.0/include -I/Library/Frameworks/cairo.framework/Headers -I/opt/local/include/pango-1.0 -I/opt/local/include/atk-1.0 -o CMakeFiles/Example.dir/Example.cpp.o -c /path/to/modules/Example.cpp
这会产生以下(clang)错误:
In file included from /path/to/parser/parser.h:69:
path/to/parser/parserTypes.h:58:26: error: expected '}'
OCURLY, CCURLY, OROUND, CROUND, OSQUARE, CSQUARE,
^
/usr/include/sys/param.h:171:16: note: expanded from macro 'CROUND'
#define CROUND (CBLOCK - 1) /* Clist rounding. */
^
/path/to/parser/parserTypes.h:56:1: note: to match this '{'
{
我能够使用#undef CROUND 解决这个问题,但显然这是一个非常临时的解决方案。
什么可能是这个问题的根源和适当的解决方案?