//MyDLL.h
#ifndef _MyDLL_H_
#define _MyDLL_H_ //前面两行指示编译器只包含这个文件一次。
#if defined EXPORT_DLL
#define DECLDIR __declspec(dllexport)
#else
#define DECLDIR __declspec(dllimport)
#endif
extern "C" //extern "C"告诉编译器该部分可以在C/C++中使用。
{
DECLDIR int add(int x, int y);
//DECLDIR int max(int x, int y);
DECLDIR void fun(void);
}
#endif
//MyDLL.cpp
#include "stdafx.h"
#include<iostream>
using namespace std;
#define EXPORT_DLL
#include "MyDLL.h"
extern "C"
{
DECLDIR int add(int x, int y)
{
return (x + y);
}
DECLDIR void fun(void)
{
cout << "Dll called!" << endl;
}
}