Possible Duplicate:
Convert some code from C++ to CC代码编译为C++,但不是为C
我有一个看起来是直的。当我告诉编译器一些代码(我使用Visual Studio 2008 Express的)编译它作为C++,它编译和链接罚款。当我尝试编译为C,虽然,它抛出这个错误:
1>InpoutTest.obj : error LNK2019: unresolved external symbol [email protected] referenced in function _main
1>InpoutTest.obj : error LNK2019: unresolved external symbol [email protected] referenced in function _main
的代码读取和写入并行端口,使用Inpout.dll。我有Inpout.lib和Inpout.dll。这里的代码:
// InpoutTest.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "stdio.h"
#include "string.h"
#include "stdlib.h"
/* ----Prototypes of Inp and Outp--- */
short _stdcall Inp32(short PortAddress);
void _stdcall Out32(short PortAddress, short data);
/*--------------------------------*/
int main(int argc, char* argv[])
{
int data;
if(argc<3)
{
//too few command line arguments, show usage
printf("Error : too few arguments\n\n***** Usage *****\n\nInpoutTest read <ADDRESS> \nor \nInpoutTest write <ADDRESS> <DATA>\n\n\n\n\n");
}
else if(!strcmp(argv[1],"read"))
{
data = Inp32(atoi(argv[2]));
printf("Data read from address %s is %d \n\n\n\n",argv[2],data);
}
else if(!strcmp(argv[1],"write"))
{
if(argc<4)
{
printf("Error in arguments supplied");
printf("\n***** Usage *****\n\nInpoutTest read <ADDRESS> \nor \nInpoutTest write <ADDRESS> <DATA>\n\n\n\n\n");
}
else
{
Out32(atoi(argv[2]),atoi(argv[3]));
printf("data written to %s\n\n\n",argv[2]);
}
}
return 0;
}
我以前问这个问题,不正确,here。
任何帮助,将不胜感激。
这些天C是否会使用错位的名字?我正在查看链接器错误中的“@ 4”和“@ 8”。看起来不像C++的名称,除非我很困惑,但那些肯定不是未修饰的函数名称。 – Steve314 2010-06-29 17:19:22
这只是你以前的问题的一个小改写:http://stackoverflow.com/questions/3142420/convert-some-code-from-c-to-c。尽量不要加倍张贴。 – 2010-06-29 17:21:01
@Evan:我再次问,因为我没有得到新的问题。抱歉。 – 2010-06-29 17:23:51