在Visual C++Express中构建C代码
Building C code in Visual C++ Express
很长一段时间前,我还在为POS设备玩C代码。我可以在VisualStudio2008中进行开发和构建。然后为了进行测试,我可以进入cygwin,编写代码并加载到设备上,或者使用附带的模拟器。在沿线的某个地方,那个虚拟盒子丢失了。
我想重新开始尝试这个设备,但在Visual Studio 2008 C++Express中构建代码时遇到了困难。
我用现有代码创建了一个新项目,将其设置为编译为C代码,并尝试构建。它抱怨找不到system.h,所以我在tools下的include目录中添加了该目录。
现在它给出408个错误。示例如下:
------ Build started: Project: TestHelloWorld, Configuration: Debug Win32 ------
Compiling...
sysutil.c
c:cygwinhomecreon_sdk_v2.3programlibsystem.h(105) : error C2054: expected '(' to follow '__pcs'
c:cygwinhomecreon_sdk_v2.3programlibsystem.h(105) : error C2085: 'disable_interrupt' : not in formal parameter list
c:cygwinhomecreon_sdk_v2.3programlibsystem.h(106) : error C2082: redefinition of formal parameter '__pcs'
c:cygwinhomecreon_sdk_v2.3programlibsystem.h(106) : error C2143: syntax error : missing ';' before 'type'
c:cygwinhomecreon_sdk_v2.3programlibsystem.h(106) : error C2085: 'enable_interrupt' : not in formal parameter list
c:cygwinhomecreon_sdk_v2.3programlibsystem.h(107) : error C2085: 'call_app_func' : not in formal parameter list
c:cygwinhomecreon_sdk_v2.3programlibsystem.h(108) : error C2082: redefinition of formal parameter '__pcs'
c:cygwinhomecreon_sdk_v2.3programlibsystem.h(108) : error C2146: syntax error : missing ',' before identifier 'DWORD'
c:cygwinhomecreon_sdk_v2.3programlibsystem.h(108) : error C2146: syntax error : missing ',' before identifier 'os_switch_app'
c:cygwinhomecreon_sdk_v2.3programlibsystem.h(108) : error C2143: syntax error : missing ';' before '('
c:cygwinhomecreon_sdk_v2.3programlibsystem.h(108) : error C2059: syntax error : ')'
c:cygwinhomecreon_sdk_v2.3programlibsystem.h(109) : error C2054: expected '(' to follow '__pcs'
c:cygwinhomecreon_sdk_v2.3programlibsystem.h(109) : error C2085: 'app5_call' : not in formal parameter list
c:cygwinhomecreon_sdk_v2.3programlibsystem.h(110) : error C2082: redefinition of formal parameter '__pcs'
c:cygwinhomecreon_sdk_v2.3programlibsystem.h(110) : error C2146: syntax error : missing ',' before identifier 'DWORD'
c:cygwinhomecreon_sdk_v2.3programlibsystem.h(110) : error C2146: syntax error : missing ',' before identifier 'app6_call'
c:cygwinhomecreon_sdk_v2.3programlibsystem.h(110) : error C2143: syntax error : missing ';' before '('
c:cygwinhomecreon_sdk_v2.3programlibsystem.h(110) : error C2059: syntax error : ')'
c:cygwinhomecreon_sdk_v2.3programlibsystem.h(111) : error C2054: expected '(' to follow '__pcs'
c:cygwinhomecreon_sdk_v2.3programlibsystem.h(111) : error C2085: 'app7_call' : not in formal parameter list
c:cygwinhomecreon_sdk_v2.3programlibsystem.h(112) : error C2082: redefinition of formal parameter '__pcs'
c:cygwinhomecreon_sdk_v2.3programlibsystem.h(112) : error C2146: syntax error : missing ',' before identifier 'DWORD'
c:cygwinhomecreon_sdk_v2.3programlibsystem.h(112) : error C2146: syntax error : missing ',' before identifier 'app8_call'
c:cygwinhomecreon_sdk_v2.3programlibsystem.h(112) : error C2143: syntax error : missing ';' before '('
c:cygwinhomecreon_sdk_v2.3programlibsystem.h(112) : error C2059: syntax error : ')'
c:cygwinhomecreon_sdk_v2.3programlibsystem.h(113) : error C2054: expected '(' to follow '__pcs'
c:cygwinhomecreon_sdk_v2.3programlibsystem.h(113) : error C2085: 'app9_call' : not in formal parameter list
c:cygwinhomecreon_sdk_v2.3programlibsystem.h(114) : error C2082: redefinition of formal parameter '__pcs'
c:cygwinhomecreon_sdk_v2.3programlibsystem.h(114) : error C2146: syntax error : missing ',' before identifier 'DWORD'
c:cygwinhomecreon_sdk_v2.3programlibsystem.h(114) : error C2146: syntax error : missing ',' before identifier 'app10_call'
c:cygwinhomecreon_sdk_v2.3programlibsystem.h(114) : error C2143: syntax error : missing ';' before '('
c:cygwinhomecreon_sdk_v2.3programlibsystem.h(114) : error C2059: syntax error : ')'
有人知道我该怎么做吗。
该代码来自设备SDK附带的示例代码。
另外,SDK附带了cygwin,它已经安装好了,我可以让示例程序没有问题,但我更像是一个C#开发人员,所以我喜欢我的IDE。我以前有过这种工作,但不记得以前是如何工作的。
请提出任何建议。
问候,
Neill
编辑-作为请求行101-115从system.h
#ifndef _SYSTEM_H_
#define _SYSTEM_H_
#include "common.h"
extern __pcs void disable_interrupt();
extern __pcs void enable_interrupt();
extern DWORD call_app_func(void * ptr,DWORD param1,DWORD param2,DWORD param3);
extern __pcs DWORD os_switch_app(BYTE app_id,DWORD param1,DWORD param2,DWORD param3);
extern __pcs DWORD app5_call(DWORD func_no,DWORD param1,DWORD param2, DWORD param3);
extern __pcs DWORD app6_call(DWORD func_no,DWORD param1,DWORD param2, DWORD param3);
extern __pcs DWORD app7_call(DWORD func_no,DWORD param1,DWORD param2, DWORD param3);
extern __pcs DWORD app8_call(DWORD func_no,DWORD param1,DWORD param2, DWORD param3);
extern __pcs DWORD app9_call(DWORD func_no,DWORD param1,DWORD param2, DWORD param3);
extern __pcs DWORD app10_call(DWORD func_no,DWORD param1,DWORD param2, DWORD param3);
谢谢!
此error C2054: expected '(' to follow '__pcs'
形式的特定编译器错误消息表示编译器正试图解码源代码行,就好像__pcs是函数名的开头一样,并且它希望标识符后面有括号,因为它希望函数参数列表。
每当我看到这一点时,都是因为缺少一个定义,它将定义__pcs到某个函数行为修饰符。例如,在Windows中,您可能有指定调用序列的东西(C标准与Pascal标准),或者另一个将用于DLL链接。
我建议你在你的头文件中搜索__pcs的定义,看看它可能在哪里定义。
看起来确实有某种-D编译器指令来定义__pcs,或者需要包含一个头文件来定义__pc。
以下是Cygwin应用程序的示例头文件include依赖关系图,这可能会有所帮助。
- FLTK 2.0构建和演示,适用于VS2019的2011年左右的代码库
- Mingw-64 在构建和安装后不会编译 openCV 代码
- Clion显示错误,但可以使用Cmake成功构建代码
- 使用 g++7 构建的代码在访问未对齐的内存时崩溃
- 无法在 geany 上运行代码。无法执行构建命令
- 在Qt/C++中从一个代码构建两个略有不同的项目
- SDL2 不是基于 VS 代码构建的
- 使用 C 代码构建 Tensorflow lite micro
- setuptools:从C++代码构建共享库,然后构建链接到共享库的 Cython 包装器
- 我无法使用可视化工作室代码构建C++
- R dyn.load "Symbol not found"错误,即使C++代码构建良好
- 将c++代码构建为共享库
- 使用现有的cpp核心代码构建Web应用程序
- C++为使用armadillo和hdf5库的简单代码构建错误
- 使用站点的编译代码构建库时,我无法解决C++中的错误 (LNK2001)
- Eclipse中的非源代码构建
- 将测试代码构建为库或可执行文件
- iOS:从c++代码构建静态库失败
- xcode 6.X arm64代码构建失败,没有任何编译或链接错误
- 如何为交叉编译的代码构建单元测试