Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / November 2006

Tip: Looking for answers? Try searching our database.

DLL exported functions Issue

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Mohammad Omer - 18 Nov 2006 11:35 GMT
I am writing code for creating DLL using vs2k5. My project is using
Crypto++ lib project, which has a function (ComputeHash), and with the
same name of function I have written in project with a little bit
change as follows

Crypto++ function:
protected: unsigned int __thiscall
CryptoPP::Deflator::ComputeHash(unsigned char const *)const

My function:
unsigned char * __stdcall ComputeHash(char *)

For exporting function I am using "__declspec(dllexport)", by using
declspec my exported functions will be name mangled (right??) and if I
do a function over loading of the same function, it also works fine.

If I want to export functions with out name mangling, using def file it
result in a link error. My understanding is that error comes because
over loading is not allowed using unmangled exported function, is that
right?
But, if I use
extern "C" unsigned char * __stdcall ComputeHash(char *)

Name mangling will be removed against this function extern "C" will
be the part of function signatures. If I have two functions, they
overload each other and wants to export these functions with out name
mangling the question is how to full fill this need? I seen that if one
function exported by def and other function exported by using extern
"C", both will be export successfully and will not be name mangled.
My first question, what is the difference of exporting function by
using extern "C" and def files?

Regards,

-aims
Bruno van Dooren [MVP VC++] - 18 Nov 2006 11:59 GMT
> My function:
> unsigned char * __stdcall ComputeHash(char *)
>
> For exporting function I am using "__declspec(dllexport)", by using
> declspec my exported functions will be name mangled (right??)

If you do nothing else, then yes. All names will be mangled.

> If I want to export functions with out name mangling, using def file it
> result in a link error. My understanding is that error comes because
> over loading is not allowed using unmangled exported function, is that
> right?

Indeed. you can export overloaded functions, but not without name mangling
because name mangling is used by the compiler to determne which function to
call.

> But, if I use
> extern "C" unsigned char * __stdcall ComputeHash(char *)
>
> Name mangling will be removed against this function extern "C" will
> be the part of function signatures.

Nope. extern "C" only behaves like that for functions that are __cdecl.
For __stdcall it won't work, and your function will still be mangled.
You can verify this with depends.exe

> overload each other and wants to export these functions with out name
> mangling the question is how to full fill this need?

Not.
As I explained above, name mangling is essential to overloading.

Signature

Kind regards,
   Bruno van Dooren
   bruno_nos_pam_van_dooren@hotmail.com
   Remove only "_nos_pam"


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.