hal9000
hal9000

Reputation: 221

Difference between Debug and Release when exporting C++ functions from DLL as C

I am building a DLL, which exports its functions as "C".

I am testing using a dummy function:

In my .cpp file

_MACRO(int) testFunction1()
{
    return 1;
}

In my header file

_MACRO(int) testFunction1();

This macro is defined as

#  define  _MACRO(ret)  extern __declspec (dllimport) ret __stdcall
#  define  _MACRO(ret)  __declspec (dllexport) ret __stdcall

Since I want these functions to be exported as C, i do

 \Debug>dumpbin /exports demo.dll

This correctly gives me an output of

 ordinal hint RVA      name

      1    0 000026C0 testFunction1 = testFunction1

But when I do the same for Release

\Release>dumpbin /exports demo.dll

I get this:

  1    0 00001080 testFunction1 = _get_startup_argv_mode

How can I make it print out the function name for release configuration? Any changes in release settings?

Upvotes: 1

Views: 459

Answers (1)

rustyx
rustyx

Reputation: 85412

What you're seeing is the result of COMDAT folding (merging of identical function definitions).

COMDAT folding is activated by default in Release mode (/OPT:ICF). To disable you can use /OPT:NOICF.

But why would you want to do that? It's not like it breaks your Release DLL or anything.

When you see testFunction1 = testFunction1 the first part is the actual export name and the second part is the corresponding debug symbol.

If you link without debug symbols, you'll see just testFunction1, without the = part.

Upvotes: 2

Related Questions