c++ 接口以c的形式定义
mycalc.h
#ifdef LIBMYLIB__EXPORTS
#define LIBMYLIB__API __declspec(dllexport)
#else
#define LIBMYLIB__API __declspec(dllimport)
#endif
#include <stdio.h>
#ifdef _WIN32 //windows平台
#define SCALL __stdcall
#else //添加linux宏定义
#define SCALL
#endif
#ifdef __cplusplus //以c的形式抛出
extern "C"{
#endif
LIBMYLIB__API int myadd(int a,int b);
LIBMYLIB__API int mysub(int a,int b);
#ifdef __cplusplus
};#endif
mycalc.cpp
#include "mycalc.h"
LIBMYLIB__API int myadd(int a,int b);
{
return a+b;
}
LIBMYLIB__API int mysub(int a,int b);
{
return a-b;
}