Dave's Brain

Browse - Programming Tips - How can I export a symbol (like a function name) from a DLL without

Date: 2009dec25
Language: C/C++
OS: Windows
Platform: MSVC++

Q.  How can I export a symbol (like a function name) from a DLL without
a leading underscore in Visual Studio?

A.  Write your function like this:

extern "C" void _stdcall MyFunction(int param1, float param2) { // Body of your function goes here as usual. // No need for declaration in a header file. // Does not have to be type "void". // Can be "BOOL" or any simple type. // The parameters can be different than this. }
Add its name to your .def file:
EXPORTS MyFunction
This will export your function undecorated and without an underscore. Just as the Windows API functions are. I tried __declspec(dllexport) and other things but they always added a leading underscore or something.

Add a comment

Sign in to add a comment
Copyright © 2008-2017, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.