QT报错expected identifier or '(' before string constant

u010075251 2014-04-30 09:27:15
各位大侠:

我这里得到一个C语言的dll库文件,然后在VS2008能够编辑成功,但是同样的代码移到QT上,加载时就报错expected identifier or '(' before string constant,坐等求解.......

如下是库文件的头文件,所有有宏MYLIBAPI定义的地函数都出现这个错误。
#ifdef __cplusplus
extern "C"
{
#endif
#define ODP_WebDataSpecVersion "V112"
#define MYLIBAPI extern "C" __declspec(dllexport)
MYLIBAPI int DATASPEC_MODECHECK(const unsigned char* Hash, int HashLen, int* Mode);
MYLIBAPI int DATASPEC_CHECKDONGLE(void);
MYLIBAPI int DATASPEC_LOGOnOffSwtich(int);
MYLIBAPI int DATASPEC_CHECKUSERNAMEANDPASSWORD( int UserMode
, int ServerLocation
, char *UserName
, char *Password
, char *RealUserName
, char *RealPassWord
, int *user_mode_level
);
MYLIBAPI int DATASPEC_INIT_ALL(void);
MYLIBAPI int DATASPEC_INIT(int Mode, int TypeConvert);
MYLIBAPI int DATASPEC_CLOSE(void);
MYLIBAPI int DATASPEC_CONNECT(int Mode);
MYLIBAPI int DATASPEC_FREE_BUFFER(char *Buffer);
MYLIBAPI int DATASPEC_CONVERT_BUFFER(int Mode, int TypeConvert, int LgIn, char *BufferIn,
int *LgOut, char **BufferOut);
MYLIBAPI int DATASPEC_READ_DATA(int Mode, int TypeData,
int *lgOut, char **bufferOut);
MYLIBAPI int DATASPEC_GENERATE_BUFFER(int Mode, int TypeGene, int Lg, char **BufferOut);
MYLIBAPI int DATASPEC_FREE_BUFFER(char *Buffer);
MYLIBAPI int DATASPEC_LOCATE_OPERATOR_ADDR(char *CHECKFILE, char *ExtWebAddr, int OperatorMode);
MYLIBAPI int DATASPEC_INIT_OPERATOR_ADDR(void);
MYLIBAPI int DATASPEC_SetSwitchFlag();
#ifdef __cplusplus
};
#endif
#endif
...全文
3339 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
DEREK_D 2016-06-16
  • 打赏
  • 举报
回复
引用 9 楼 u010075251 的回复:
已解,原因就是DLL文件中,又套用其所长另外一个DLL文件,相关DLL文件,没有复制过去。
同样的问题,"另一个dll"?是export.dll吗?
gao-wei-89 2014-09-15
  • 打赏
  • 举报
回复
我也遇到了同样的问题,楼主可以说的具体些吗 谢谢
u010075251 2014-05-04
  • 打赏
  • 举报
回复
再顶一下,仍然没有找到答案。
u010075251 2014-05-04
  • 打赏
  • 举报
回复
已解,原因就是DLL文件中,又套用其所长另外一个DLL文件,相关DLL文件,没有复制过去。
u010075251 2014-04-30
  • 打赏
  • 举报
回复
#ifdef __cplusplus extern "C" { #endif #define ODP_WebDataSpecVersion "V112" #define MYLIBAPI extern "C" __declspec(dllexport) 另外我查过很资料,好像说如果在C语言中声明了extern "C",然后编辑器就会报错expected identifier or '(' before string constant。 这里很明显出现了两次,不知道这个是不是更本原因,但我注释掉一个,就出现了另一个错误“file not recognized: File format not recognized。
u010075251 2014-04-30
  • 打赏
  • 举报
回复
相反如果将"C" 注释掉,会报另外一个错误 "file not recognized: File format not recognized" “#define MYLIBAPI extern /*"C" */ __declspec(dllexport)
u010075251 2014-04-30
  • 打赏
  • 举报
回复
我试过如果注释掉__declspec(dllexport),仍然报同样的错误。 #define MYLIBAPI extern "C" //__declspec(dllexport)
火头军 2014-04-30
  • 打赏
  • 举报
回复
qt 不需要__declspec(dllexport)
u010075251 2014-04-30
  • 打赏
  • 举报
回复
自已先顶一下。
u010075251 2014-04-30
  • 打赏
  • 举报
回复
虽然不明白你这样做的目的是什么,但是我还是试了一把。 但现在所有有宏MYLIBAPI的函数处,都报错“ex[ected '=',',',;','asm' or' -attribute__' before 'int' #ifdef __cplusplus #define MYLIBAPI extern "C" __declspec(dllexport) #esle #define MYLIBAPI __declspec(dllexport) #endif MYLIBAPI int DATASPEC_MODECHECK(const unsigned char* Hash, int HashLen, int* Mode); MYLIBAPI int DATASPEC_CHECKDONGLE(void); MYLIBAPI int DATASPEC_LOGOnOffSwtich(int); MYLIBAPI int DATASPEC_CHECKUSERNAMEANDPASSWORD( int UserMode
lm_whales 2014-04-30
  • 打赏
  • 举报
回复
//先这么着
#ifdef __cplusplus
#define MYLIBAPI     __declspec(dllexport)
#endif
或者
#ifdef __cplusplus
#define MYLIBAPI  extern "C"   __declspec(dllexport)
#esle 
#define MYLIBAPI     __declspec(dllexport)
#endif

//VC 自动生成的 
#ifdef XXX_EXPORTS
#defineXXX_API __declspec(dllexport)
#else
#define XXX_API __declspec(dllimport)
#endif

24,854

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 工具平台和程序库
社区管理员
  • 工具平台和程序库社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧