错误:在 Linux 上编译代码时,'...'之前需要类型说明符

Error: expected type-specifier before '...' when compiling code on linux

本文关键字:说明符 类型 Linux 编译 代码 错误      更新时间:2023-10-16

所以,我有一些依赖于平台的代码,它使用winusb或libusb在Linux和Windows上编译。我使用预编译器指令来包含正确的头文件并创建正确的接口:

#include "../path/myusbint.hpp"
#ifdef WIN32 
#include "../path/winusbint.h"
#else
#include "../path/libusbint.h"
#endif
boost::shared_ptr<myusbinerface> usbinterface;
#ifdef WIN32
    usbinterface.reset(new winusbint);
#else
    usbinterface.reset(new libusbint);
#endif

Windows上它可以很好地编译,但是在Linux(gcc(上,我收到错误:

error: expected type-specifier before `libusbint'
error: expected ')' before `libusbint'

可能,您尚未向我们展示的某些代码在尚未声明的位置使用名为 USBInterfaceLibUSB 的类型。您需要向我们展示导致错误的实际代码才能确定。

如果这是正确的类型名称,请确保使用它的任何文件都包含定义该类型的标头,或者如果不需要完整定义,则包含前向声明。

如果名称错误,请将其更改为正确的名称。也许应该myusbinerface匹配您发布的代码?或者,也许您在真实代码中拼写正确(myusbinterface(?