我的编码收到C4430和C2144错误. [英] I am receiving C4430 and C2144 errors for my codings.
问题描述
我是Visual C ++的新手.我正在尝试为我的练习制作一个简单的DLL.我的编码如下:
CB.CPP
I am new to Visual C++. I am trying to make a simple DLL for my practice. My coding is as follows:
CB.CPP
#include "stdafx.h"
#include "CB.h"
extern "C" EXPORT int WINAPI sum (int x, int y)//C2144 and C4430
{
return x+y;
}
和CB.H
and CB.H
#define CBExport __declspec(dllexport)
#ifdef __cplusplus
extern "C"
{
#endif
extern "C" EXPORT int WINAPI sum (int x, int y);//C2144 and C4430
#ifdef __cplusplus
}
#endif
尝试构建此编时,我收到错误C4430和C2144. C2144错误如下:
1> d:\ context broker \ cb \ cb \ cb \ cb.h(14):错误C2144:语法错误:"int"之前应加上;"
和C4330错误如下:
1> d:\ context broker \ cb \ cb \ cb \ cb.h(14):错误C4430:缺少类型说明符-假定为int.注意:C ++不支持default-int
I am receiving the errors C4430 and C2144 while trying to build this prog. The C2144 error is as follows:
1>d:\context broker\cb\cb\cb\cb.h(14) : error C2144: syntax error : ''int'' should be preceded by '';''
and C4330 error is follows:
1>d:\context broker\cb\cb\cb\cb.h(14) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
推荐答案
从
更改
#define CBExport __declspec(dllexport)
#define CBExport __declspec(dllexport)
到
to
#define EXPORT __declspec(dllexport)
顺便说一句,您不应该复制"extern
"子句.
BTW you shouldn''t duplicate the ''extern
'' clause.
这篇关于我的编码收到C4430和C2144错误.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!