Possible Duplicate:
Convert some code from C++ to CC 코드는 C++로 컴파일하지만 C
내가 컴파일러에게하면 바로 C를 것으로 보인다 몇 가지 코드를 가지고로로 컴파일 (나는 비주얼 스튜디오 2008 익스프레스를 사용하고 있습니다)하지 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이 둘 다 있습니다. 여기 코드는 : 나는 이전에 잘못이 질문에, here을 요청
// 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;
}
.
도움을 주시면 감사하겠습니다.
extern "C++" {
short _stdcall Inp32(short PortAddress);
void _stdcall Out32(short PortAddress, short data);
}
요즘 C가 맹 글링 된 이름을 사용합니까? 나는 링커 오류에서'@ 4 '와'@ 8'을보고있다. 내가 심각하게 혼동하지 않는 한, C++ 이름 맹 글링처럼 보이지는 않지만, 그것들은 확실히 장식되지 않은 함수 이름이 아닙니다. – Steve314
이것은 이전 질문에 대한 간략한 설명입니다. http://stackoverflow.com/questions/3142420/convert-some-code-from-c-to-c. 두 번 게시하지 마십시오. –
@ 에반 : 다른 질문에 대한 새로운 의견을 얻지 못했기 때문에 다시 질문했습니다. 죄송합니다. –