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.