__declspec (dllexport) and. def (module definition files) Define the difference between the exported functions in a DLL

Source: Internet
Author: User

The original thought is not to use the. def file in the DLL, and add __declspec (dllexport) adornments directly before the function that needs to be exported. But when it comes to exporting stdapi __declspec (dllexport) DllGetClassObject, Just prompt"warning C4518: "__declspec (dllexport)": Unexpected storage class or type descriptor encountered here; ignored"(I'm using vc.net.2003). STDAPI This macro expands out to be extern"C"HRESULT __stdcall.extern "C"Must be placed at the front of the function declaration, and __declspec (dllexport) can not be placed after __stdcall (my test results here, __declspec (dllexport) Stdapi and STDAPI __ Declspec (dllexport) is not, the former error, because extern"C"be sure to put it first; the latter is the warning mentioned above. The first is to find out how to export stdapi functions, but nothing to find. Confused on the internet search for a while. The search results are recorded as follows (possibly confusing)1The export of the STDAPI function needs to be declared in the. def (module definition file), and with the private adornment, the private adornment's exported function can only be called dynamically because it is not compiled into the export file. 2A function exported with a. def file whose name is defined as we wish, and when exported with __declspec (dellexport), there is a corresponding decorated name, depending on the compiler, its decorated name is different. 3The export defined by __declspec (dllexport) is used for implicit chaining (static invocation) of the same compiler, while the. def export function can determine that the exported function name will not be different for different compilers and can be used for other development tool calls. In general, the. def is used in COM to derive the function.
Reprinted from: http://blog.csdn.net/mimong_lin/article/details/2628408

__declspec (dllexport) and. def (module definition files) Define the difference between the exported functions in a DLL

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.