【发布时间】:2012-09-14 13:11:11
【问题描述】:
我真的是 C 的菜鸟。我只需要编译一个 ANSI C 源代码来获得一个 dll。 在编译期间我收到此错误:
C2491: 'SelectML': definition of dllimport function not allowed
其中 SelectML 是具有此定义的公共函数:
int CALLINGCONV SelectML(WORD fid, int nSlot)
{
WORD SW;
int x;
BYTE pSend[2];
pSend[0]=(BYTE)((fid&0xff00)>>8);
pSend[1]=(BYTE)(fid&0x00ff);
x=SendAPDUML(hCards[nSlot],APDU_SELECT,2,0,pSend,0,&SW);
if (x!=C_OK) return x;
if (SW!=0x9000) return SW;
return C_OK;
}
我确定C源是好的,也许只是Visual Studio的配置……
这是另一个链接的标题:
#ifndef LIBSIAECARDT_H
#define LIBSIAECARDT_H
#ifdef __cplusplus
extern "C" {
#endif
#if !defined(USE_STDCALL)
#define USE_STDCALL 1
#endif
#ifdef _WIN32
# if USE_STDCALL == 1
# define CALLINGCONV_1 _stdcall
# else
# define CALLINGCONV_1
# endif
# if defined(LIBSIAE_EXPORTS)
# define LIBSIAEAPI __declspec(dllexport)
# else
# define LIBSIAEAPI __declspec(dllimport)
# endif
# define CALLINGCONV LIBSIAEAPI CALLINGCONV_1
#else // ! _WIN32
# define CALLINGCONV
# define LIBSIAEAPI
# define CALLINGCONV_1
typedef unsigned int UINT;
#endif // _WIN32
【问题讨论】:
-
那么
CALLINGCONV是什么?看起来像是导致错误,编译器甚至会告诉你究竟是怎么回事。 -
CALLINGCONV 定义在包含的标头中
标签: c visual-studio compiler-construction