.def files C/C++ DLLs

后端 未结 6 1755
我在风中等你
我在风中等你 2020-11-30 04:31

I am not understanding the point of using .def files with DLLs.

It seems that it replaces the need to use explicit exports within your DLL code (ie. explicit __decls

6条回答
  •  南方客
    南方客 (楼主)
    2020-11-30 04:58

    My understanding is that .def files provide an alternative to the __declspec(dllexport) syntax, with the additional benefit of being able to explicitly specify the ordinals of the exported functions. This can be useful if you export some functions only by ordinal, which doesn't reveal as much information about the function itself (eg: many of the OS internal DLL's export functions only by ordinal).

    See the reference page.

    Note that the names in the .def file must match the names in the binary. So if you using C or C++ with 'extern "C" { ... }', the names will not be mangled; otherwise you must use the correct mangled names for the specific version of the compiler used to generate the DLL. The __declspec() function does this all automatically.

提交回复
热议问题