69,336
社区成员
发帖
与我相关
我的任务
分享
正在编译...
1>MyDll.c
1>f:\windows编程\dll1\dll1\mydll.h(7) : error C2059: 语法错误 : “字符串”
1>f:\windows编程\dll1\dll1\mydll.h(8) : error C2059: 语法错误 : “字符串”
1>生成日志保存在“file://f:\Windows编程\dll1\dll1\Debug\BuildLog.htm”
1>dll1 - 2 个错误,0 个警告
MyDll.h
#include <windows.h>
#define MYDLLAPI extern "C" _declspec(dllexport)
#include "MyDll.h"
int g_nResult;
int Add(int nLeft,int nRight)
{
g_nResult = nLeft + nRight;
return(g_nResult);
}
MyDll.c
#include <windows.h>
#define MYDLLAPI extern "C" _declspec(dllexport)
#include "MyDll.h"
int g_nResult;
int Add(int nLeft,int nRight)
{
g_nResult = nLeft + nRight;
return(g_nResult);
}
#include<Windows.h>
#define MYLIBAPI extern "C" __declspec(dllexport)
#include"mylib.h"
int add(int nleft,int nright){
return nleft+nright;
}
#ifndef MYLIB
#define MYLIB
#ifdef MYLIBAPI
#else
#define MYLIBAPI extern "C" __declspec(dllimport)
#endif
MYLIBAPI int add(int nleft,int nright);
#endif
MyDll.h
#ifndef MyDLLAPI
#include <windows.h>//没用到API,你包含它干什么
#define MYDLLAPI extern "C" _declspec(dllimport)对于DLL来说,头文件是给使用这个dll文件的人看的,也是给使用这个dll的人用的,所以应该用导入,当然你可不这么做
#include "MyDll.h"//你自己包含自己干什么
#endif
int g_nResult;
int Add(int nLeft,int nRight);这里只需要声明,不需要定义,不要忘记头文件的作用
#include <windows.h>//这里同样不需要这个头文件
#define MYDLLAPI extern "C" _declspec(dllexport)
#include "MyDll.h"
int g_nResult;//在头文件中有相关的声明了,在这里不需要了
int Add(int nLeft,int nRight)
{
g_nResult = nLeft + nRight;
return(g_nResult);
}
#ifndef MYDLL_H_
#define MYDLL_H_
#include <windows.h>
#define MYDLLAPI extern "C" _declspec(dllexport)
#include "MyDll.h"
int g_nResult;
int Add(int nLeft,int nRight)
{
g_nResult = nLeft + nRight;
return(g_nResult);
}
#endif