我正在一个项目中,我需要通过设备制造商提供的API控制某些硬件。有给出的代码示例,可以很好地编译。 API随附的.h-header文件中定义了某些功能。当我将其中一个编程示例复制并粘贴到我的.c文件(包括同一文件夹中引用的.h-Headers)中时,我通过VS 2017本机工具命令提示符访问的cl
编译器抛出异常/错误,主要是C2059和C2061错误。例如:
Microsoft (R) C/C++ Optimizing Compiler Version 19.10.25019 for x64
Copyright (C) Microsoft Corporation. All rights reserved.
pco_controller.c
c:\users\optical microscope\desktop\vinzenz\pco.edge 5.5\pco_controller\sc2_SDKS
tructures.h(155): error C2061: syntax error: identifier 'SHORT'
c:\users\optical microscope\desktop\vinzenz\pco.edge 5.5\pco_controller\sc2_SDKS
tructures.h(156): error C2061: syntax error: identifier 'ZZwAlignDummy'
c:\users\optical microscope\desktop\vinzenz\pco.edge 5.5\pco_controller\sc2_SDKS
tructures.h(156): error C2059: syntax error: ';'
c:\users\optical microscope\desktop\vinzenz\pco.edge 5.5\pco_controller\sc2_SDKS
tructures.h(157): error C2061: syntax error: identifier 'dwStatusDll'
c:\users\optical microscope\desktop\vinzenz\pco.edge 5.5\pco_controller\sc2_SDKS
tructures.h(157): error C2059: syntax error: ';'
c:\users\optical microscope\desktop\vinzenz\pco.edge 5.5\pco_controller\sc2_SDKS
tructures.h(158): error C2061: syntax error: identifier 'dwStatusDrv'
c:\users\optical microscope\desktop\vinzenz\pco.edge 5.5\pco_controller\sc2_SDKS
tructures.h(158): error C2059: syntax error: ';'
c:\users\optical microscope\desktop\vinzenz\pco.edge 5.5\pco_controller\sc2_SDKS
tructures.h(159): error C2059: syntax error: '}'
当我们查看sc2_SDKStructures.h
文件时,我们发现:
typedef struct // Buffer list structure for PCO_WaitforBuffer
{
SHORT sBufNr;
WORD ZZwAlignDummy;
DWORD dwStatusDll;
DWORD dwStatusDrv; // 12
} PCO_Buflist;
由于我是C编程的新手,所以我不理解这些错误,并且鉴于标头是由硬件制造商提供的,所以我不明白为什么它们的代码应该是错误的。