在编译Qt时报如下错误:
In file included from ../ZB/posix_qextserialport.h:8:0,
from ../ZB/qextserialport.h:7,
from ../ZB/mainwindow.h:40,
from ../ZB/main.cpp:4:
../ZB/qextserialbase.h:131:18: error: expected unqualified-id before numeric constant
make: *** [main.o] Error 1
在qextserialbase.h的131行处:
struct PortSettings{
BaudRateType BaudRate;
DataBitsType DataBits;
ParityType Parity;
StopBitsType StopBits;
FlowType FlowControl;
long Timeout_Millisec;
};
在serialport.h中有个宏定义:
#define BaudRate 9600
就把结构体里的BaudRate结替换掉了。
所以会出现这种情况。
在使用Qt进行项目开发时,遇到在编译过程中出现错误提示的情况。通过检查代码,发现是在qextserialbase.h文件的第131行出现了预期未合格标识符前的数值常量错误。问题出现在结构体PortSettings中BaudRate类型的定义上。通过替换宏定义BaudRate为实际数值,解决了该错误。本文将详细解析这一问题的解决过程。
1847

被折叠的 条评论
为什么被折叠?



