在Visual C++Express中构建C代码

Building C code in Visual C++ Express

本文关键字:代码 构建 Visual C++Express      更新时间:2023-10-16

很长一段时间前,我还在为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依赖关系图,这可能会有所帮助。