一、_stdcall
被这个关键字修饰的函数,其参数都是从右向左通过堆栈传递的(__fastcall 的前面部分由ecx,edx传), 函数调用在返回前要由被调用者清理堆栈。
这个关键字主要见于Microsoft Visual C、C++。GNU的C、C++是另外一种修饰方式:__attribute__((stdcall))
1.
MathFunsStd.cpp:
int _stdcall add(int a, int b) { return a+b; } int _stdcall subtract(int a, int b) { return a-b; } int _stdcall multiple(int a, int b) { return a*b; }
MathFunsStd.def:
LIBRARY MathFunsStd
EXPORTS
add
subtract
multiple
2.MathFuns.cpp
int add(int a, int b) { return a+b; } int subtract(int a, int b) { return a-b; } int multiple(int a, int b) { return a*b; }
MathFuns.def
LIBRARY MathFuns
EXPORTS
add
subtract
multiple
3.UseHeaderAPI
MathFunsUseHeader.h
#ifdef MathFunsUseHeaderAPI #else #define MathFunsUseHeaderAPI _declspec(dllimport) #endif MathFunsUseHeaderAPI int add(int a,int b); MathFunsUseHeaderAPI int subtract(int a,int b); MathFunsUseHeaderAPI int multiple(int a, int b); #define MathFunsUseHeaderAPI _declspec(dllexport) #include "MathFunsUseHeader.h"
MathFunsUseHeader.cpp
int add(int a, int b) { return a+b; } int subtract(int a, int b) { return a-b; } int multiple(int a, int b) { return a*b; }
三、调用