-
September 8th, 2009, 07:06 AM
#1
DLL exporting function names - aliases
Hi,
my problem is, that I have to compile a few programs with VS2005 and other programs with Watcom (OpenWatcom to be exact). A lot of DLLs, most of them with stdcall calling convention.
Watcom is exporting all functions twice, as the dependency walker shows:
Code:
Function EntryPoint
_grafixLibFileInfo@4 0x000010A7
grafixLibFileInfo 0x000010A7
Visual Studio is exporting the functions only once
Code:
Function EntryPoint
_grafixLibFileInfo@4 0x00011267
I'm using
Code:
#define DLL_EXPORT __declspec(dllexport) __stdcall
long DLL_EXPORT grafikLibFileInfo(struct GRAFLIBFILE *gLibFile)
{
...
}
no def file
Is there any chance, to export the functions like Watcom does?
Otherwise I have to change all the GetProcAddress calls from e.g.
grafixLibFileInfo to _grafixLibFileInfo@4
Thanks in advance
-
September 8th, 2009, 07:55 AM
#2
Re: DLL exporting function names - aliases
What about exporting functions once, but without C++ name mangling, grafixLibFileInfo and not _grafixLibFileInfo@4 ?
This can be done by using extern "C":
http://msdn.microsoft.com/en-us/libr...3s(VS.80).aspx
-
September 8th, 2009, 08:26 AM
#3
Re: DLL exporting function names - aliases
Originally Posted by Alex F
What about exporting functions once, but without C++ name mangling, grafixLibFileInfo and not _grafixLibFileInfo@4 ?
This can be done by using extern "C"
it's plain C - the DLL I'm talking about at least.
This name decoration with underscore is an old 16 bit thing - afaik.
Add the @4 is showing the bytecount of the parameters. If two long would be passed, there would be a @8 - it's not a C++ function name.
But thanks nevertheless for your reply.
-
September 8th, 2009, 09:12 AM
#4
Re: DLL exporting function names - aliases
Originally Posted by Alex F
_grafixLibFileInfo@4 already is extern "C".
Best regards,
Igor
-
September 8th, 2009, 09:17 AM
#5
Re: DLL exporting function names - aliases
Is there any chance, to export the functions like Watcom does?
Sure, just build it with Watcom.
Now getting serious. VC++ mangles the function this way, and there is no other way to change the behavior, except one of explicit specifications: - .def file or
- #pragma comment(linker, "/export:grafixLibFileInfo=_grafixLibFileInfo@4")
Best regards,
Igor
-
September 8th, 2009, 11:38 AM
#6
Re: DLL exporting function names - aliases
Originally Posted by Igor Vartanov
Sure, just build it with Watcom.
I'm quite a Watcom-fan :-) the debugger is really great - just missing the possibility to code in teh debugger like in VS and changing from debugging to coding.
Originally Posted by Igor Vartanov
- .def file or
- #pragma comment(linker, "/export:grafixLibFileInfo=_grafixLibFileInfo@4")
Thanks for responding. I'll give the pragma a try ... curious whether that'll work.
-
September 8th, 2009, 04:55 PM
#7
Re: DLL exporting function names - aliases
Originally Posted by FrankieH
I'll give the pragma a try ... curious whether that'll work.
I'll be surprized if that won't.
Code:
// 17.cpp
extern "C" __declspec(dllexport)
int __stdcall foo(int a) { return 0; }
#pragma comment(linker, "/export:foo=_foo@4")
Code:
D:\Temp\17>cl 17.cpp /link /dll /out:17.dll
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 14.00.50727.762 for 80x86
Copyright (C) Microsoft Corporation. All rights reserved.
17.cpp
Microsoft (R) Incremental Linker Version 8.00.50727.762
Copyright (C) Microsoft Corporation. All rights reserved.
/out:17.exe
/dll
/out:17.dll
17.obj
Creating library 17.lib and object 17.exp
D:\Temp\17>exports 17.dll
ModuleType:
PE executable (DLL)
Subsystem:
Win32 GUI
ModuleName:
17.dll
Exported Info: BaseOfOrdinals = 1
NumberOfNames = 2
NumberOfFunctions = 2
RelVirtAddr Ord Hint ExportedFuncName
0x00001000 1 0 _foo@4
0x00001000 2 1 foo
Best regards,
Igor
-
September 21st, 2009, 10:23 AM
#8
Re: DLL exporting function names - aliases
thanks again - it's working fine ....
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|