I've run into a strange name mangling problem using VC++ 2005 and VC+ 2008.
A given class function (example)
virtual bool OnValueDecrement(CExtGridWnd & wndGrid,
LONG nColNo,LONG nRowNo,INT nColType,INT nRowType);
is being imported as
?OnValueDecrement@CExtGridCell@@UAE_NAAVCExtGridWnd@@JJHH@Z
The third party DLL I'm using here exports this function as
?OnValueDecrement@CExtGridCell@@UAE_NXZ
I suppose this is a compiler/switch issue. Any clues?
There appears to be a mis-match between what you think the interface
is and what it is.
The undname utility shows:
Undecoration of :-
"?OnValueDecrement@CExtGridCell@@UAE_NAAVCExtGridWnd@@JJHH@Z"
is :- "public: virtual bool __thiscall
CExtGridCell::OnValueDecrement(class CExt
GridWnd &,long,long,int,int)"
Undecoration of :- "?OnValueDecrement@CExtGridCell@@UAE_NXZ"
is :- "public: virtual bool __thiscall
CExtGridCell::OnValueDecrement(void)"
Dave
thanks a lot for your answer. However I'm not sure what it means :-)
The point is that no matter what compiler/linker settings I'm using I can't
get my app to import this function as
"?OnValueDecrement@CExtGridCell@@UAE_NXZ". I wouldn't mind but I can't debug
it (unknown symbol).
In addition when I compile the third party DLL (sources are available) the
exported symbol is
"?OnValueDecrement@CExtGridCell@@UAE_NAAVCExtGridWnd@@JJHH@Z " ( as shown in
depends.exe). I'm using the makefile delivered with the source code.
Any clues?
Christian
Christian,
From what you originally reported, you were apparently using the
function as:
CExtGridCell::OnValueDecrement(
class CExt GridWnd &,long,long,int,int)"
whereas the DLL exported it as:
CExtGridCell::OnValueDecrement(void)
However, from what you now say, things are reversed!
>The point is that no matter what compiler/linker settings I'm using I can't
>get my app to import this function as
>"?OnValueDecrement@CExtGridCell@@UAE_NXZ". I wouldn't mind but I can't debug
>it (unknown symbol).
>
>In addition when I compile the third party DLL (sources are available) the
>exported symbol is
>"?OnValueDecrement@CExtGridCell@@UAE_NAAVCExtGridWnd@@JJHH@Z " ( as shown in
>depends.exe). I'm using the makefile delivered with the source code.
... so I'm not sure where the mis-match is - other than you presumably
have conflicting definitions between the source used to build the DLL
and the header file you're using to reference the library from your
application.
Dave
Dave,
in the header file the function is declared as
----------------------------------------
virtual bool OnValueDecrement(
CExtGridWnd & wndGrid,
LONG nColNo,
LONG nRowNo,
INT nColType,
INT nRowType
);
-------------------------------------
This matches the declaration you expected. This also explains the symbols
found in the DLL I compiled myself. It does not explain the symbols in the
precompiled third-party DLL :-(
Are there any compiler switches to modify the way VC decorates the exported
symbols? IMHO this kind of complex decoration is just a way to accomplish
some kind of runtime check...
Christian
I can only suggest that you ask the vendor of the library what the
problem is.
>Are there any compiler switches to modify the way VC decorates the exported
>symbols?
Things like __cdecl and __stdcall will affect the name, as well as
exporting names using .DEF files. See the topic titled "Decorated
Names" in MSDN for a little more information.
> IMHO this kind of complex decoration is just a way to accomplish
>some kind of runtime check...
Mangling serves to ensure that the linking is correct at build time,
not at run-time.
Dave
Joseph M. Newcomer [MVP]
email: newc...@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
yes I'm quite sure it was MSVC 8 since the DLL contains some ASCII traces.
I'm using VC8 as well. I guess that's not the problem.
__stdcall is uses as calling convention here. __cdecl and __fastcall make a
difference (already tried it) but I never get the same result as in the
precompiled DLL.
Looks like a DEF file was used in this case (for whatever reason) unless
someone's got another idea...
Christian