错误:粘贴"tmp_UINT"和"+"未提供有效的预处理令牌
error: pasting "tmp_UINT" and "+" does not give a valid preprocessing token
我有一个宏定义为:
#define GET_GENERIC_VAL(val_type, fmt_printf, prefix, suffix)
val_type tmp_ ## val_type;
rtc = (*(INOBJECT**)pObj)->getGeneric(meth, &(tmp_ ## val_type));
if (rtc == -1) {
TRACE("Error: unable to get method for " #val_type " attribute " << attribute << " of object " << name);
return -1;
}
sprintf(valueStr, fmt_printf, (prefix)(tmp_ ## val_type ## suffix));
并在开关大小写中调用此宏为:
switch (var_type) {
case 'u' : { GET_GENERIC_VAL(UINT ,"%lu",UINT , + 0 ); break; }
case 'i' : { GET_GENERIC_VAL(INT ,"%ld",INT , + 0 ); break; }
case 's' : { GET_GENERIC_VAL(STRING ,"%s" ,const char *, + ' ' ); break; }
case 'n' : { GET_GENERIC_VAL(NUMBER ,"%s" ,const char *, .toString()); break; }
case 'b' : { GET_GENERIC_VAL(BYTESTRING,"%s" ,const char *, .toString()); break; }
case 'd' : { GET_GENERIC_VAL(DATE ,"%s" ,const char *, .toString()); break; }
case 't' : { GET_GENERIC_VAL(TIME ,"%s" ,const char *, .toString()); break; }
default : {
TRACE("Unknown type of attribute : type '" << var_type << "' for attribute '" << attribute << "' of object " << name << ".");
return -1;
}
}
我试图在 gcc 编译器上编译它,但编译器给出了以下错误:
error: pasting "tmp_UINT" and "+" does not give a valid preprocessing token
error: pasting "tmp_INT" and "+" does not give a valid preprocessing token
error: pasting "tmp_STRING" and "+" does not give a valid preprocessing token
error: pasting "tmp_NUMBER" and "." does not give a valid preprocessing token
error: pasting "tmp_BYTESTRING" and "." does not give a valid preprocessing token
error: pasting "tmp_DATE" and "." does not give a valid preprocessing token
error: pasting "tmp_TIME" and "." does not give a valid
任何人都可以帮助解决这个问题吗? 在SUN平台上编译时,它工作正常。但是Linux的错误。
你的问题是错误的标记化:
sprintf(valueStr, fmt_printf, (prefix)(tmp_ ## val_type ## suffix));
从您使用宏的方式来看,您不想创建一个预处理器令牌,而是只想添加后缀。
试试这个:
sprintf(valueStr, fmt_printf, (prefix)(tmp_ ## val_type suffix));
相关文章:
- 错误:无效的预处理指令 #i 的意思是 #if?
- C++预处理会生成变量成员、资源库和映射
- 使用预处理指令检查是否包含标头?
- 预处理的 C/C++ 文件是否特定于计算机?
- 使用 GCC 对 C 文件进行部分预处理(不删除 "define" 指令)
- 在 CPLEX 中求解线性规划,无需剪切和预处理
- CPP -D 选项,用于预处理 Fortran 代码
- 错误:粘贴"tmp_UINT"和"+"未提供有效的预处理令牌
- 任务计划程序库的预处理不起作用 - 多定义错误
- Eclipse 问题 - 编译期间不考虑 .c 和 .cpp 文件中定义的预处理
- 使用python预处理后,C++(opencv)中的垫子类型数据与image_to_array相同
- Howo 使用 cl 预处理为 masm 组装生成一个单独的文件
- 我有一个预处理的 C/C++ 源文件 (cacti.i).如何从这个 .i 文件生成可执行二进制文件,以便我可以像 ./
- 如何使用Visual Studio C/C++编译器(cl.exe)来预处理我的objective-C代码
- 如何有效地处理Teamcenter ITK C++代码中的错误
- 是具有预处理前分支实现的结构违反ODR
- 使用OOP有效地处理和读取轨迹文件
- 有没有办法使用 clang 有效地编译已经预处理过的文件
- 错误:粘贴"Java_com_my_packagename_myClass_myMethod"和"("未提供有效的预处理令牌
- 在预处理条件中使用布尔字面值是否有效?