_declspec(dllexport)与_declspec(dllimport)

_declspec(dllexport)作用:

These attributes explicitly define the DLL's interface to its client, which can be the executable file or another DLL. Declaring functions as dllexport eliminates the need for a module-definition (.DEF) file, at least with respect to the specification of exported functions.

注意: 

dllexport of a C++ function will expose the function with C++ name mangling. If C++ name mangling is not desired, either use a .def file (EXPORTS keyword) or declare the function as extern "C".

 

_declspec(dllimport)是在别的程序里面调用的时候需要进行的声明。只有在DLL内部dllexport之后,在外部才可以被import。

 

参考:

dllexport, dllimport

程序中使用动态连接库 && _declspec(dllexport)与_declspec(dllimport)
Using extern to Specify Linkage
posted on 2010-10-09 11:16  lbsx  阅读(246)  评论(0编辑  收藏  举报