NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

The DLL functionname display shows a wrong functionname

Until now I created my dll libraries with the gcc (MinGWTools) and never had problems.

Now i have to create c++ dlls and want use the g++ compiler.
The Problem is, if i want to specify a module in the c/c++ module adapter, and i select a function of the chosen dll, the display shows a wrong funtion name.

For example:

it should show the functionname :
"detailedCommand"
but it shows
"Z15detailedCommandP12_RemoteSlavesiz"

the header declaration of the dll looks like:

__declspec(dllexport) int detailedCommand(RemoteSlave*, short, int,...);

If i compile the same file with the gcc everything works fine, but if i compile the file with the g++, i get these display errors.

Do you have an idea what the problem can be?
thanks.
0 Kudos
Message 1 of 3
(3,117 Views)
I think i've got a solution.

I changed the declaration to:

extern "C" __declspec(dllexport) int detailedCommand(RemoteSlave*, short, int,...);

and everything works fine.
Do you know another solution for the problem?

Message Edited by giese_m on 01-24-2006 07:53 AM

0 Kudos
Message 2 of 3
(3,119 Views)

The reason this happens is that in C++, you can have multiple overloaded methods all with the same name. To differentiate them in the dll, the compiler adds extra coding characters based on the method signature. This is called name mangling and it is compiler dependent.  I'm not sure, but I think TestStand knows how to demangle names created by Visual C++. However, I'm sure TestStand does not know how to demangle g++ names.

Declaring the function extern "C" is the right solution for your case. Since C does not support overloads, you cannot have two extern "C" functions with the same name, so the name is not mangled.

0 Kudos
Message 3 of 3
(3,101 Views)