Overloaded functions in C++ DLL def file

Tags: dll c c++

I'm writing a C/C++ DLL and want to export certain functions which I've done before using a .def file like this


with the code defined as this, for example:

int Foo(int a);
void Bar(int foo);

However, what if I want to declare an overloaded method of Foo() like:

int Foo(int a, int b);

As the def file only has the function name and not the full prototype I can't see how it would handle the overloaded functions. Do you just use the one entry and then specify which overloaded version you want when passing in the properly prototyped function pointer to LoadLibrary() ?

Edit: To be clear, this is on Windows using Visual Studio 2005

Edit: Marked the non-def (__declspec) method as the answer...I know this doesn't actually solve the problem using def files as I wanted, but it seems that there is likely no (official) solution using def files. Will leave the question open, however, in case someone knows something we don't have overloaded functions and def files.


Systax for EXPORTS definition is:

entryname[=internalname] [@ordinal [NONAME]] [PRIVATE] [DATA]

entryname is the function or variable name that you want to export. This is required. If the name you export is different from the name in the DLL, specify the export's name in the DLL with internalname.

For example, if your DLL exports a function, func1() and you want it to be used as func2(), you would specify:


Just see the mangled names (using Dependency walker) and specify your own functions name.

Source: http://msdn.microsoft.com/en-us/library/hyx1zcd3(v=vs.71).aspx

Edit: This works for dynamic DLLs, where we need to use GetProcAddress() to explicitly fetch a functions in Dll.

By : null

There isn't a language or version agnostic way of exporting an overloaded function since the mangling convention can change with each release of the compiler.

This is one reason why most WinXX functions have funny names like *Ex or *2.

This video can help you solving your question :)
By: admin