__declspec(dllexport) required on function declaration in dll source code?  
Author Message
georgeob





PostPosted: Visual C++ General, __declspec(dllexport) required on function declaration in dll source code? Top

With the help of one of the people that posts messages on this website, I was able to get a C++ DLL to work with a VB 6.0 calling program.  The function definition in the .cpp file has the __stdcall decoration on the function name, but it doesn't have the __declspec(dllexport) decoration on it.  It seems to be working fine without it, but is it required for some reason   If so what would that reason be   Does the compiler put it in automatically when you compile it, or is it really required at all

 

George




Visual C++16  
 
 
Viorel.





PostPosted: Visual C++ General, __declspec(dllexport) required on function declaration in dll source code? Top

I think __declspec(dllexport) is not required when the function is enumerated in the module-definition file (DEF).


 
 
Mike Danes





PostPosted: Visual C++ General, __declspec(dllexport) required on function declaration in dll source code? Top

To add some details:

in vb instead of summer, I did not try).

Using a DEF file allows you to control the name which is exported so you can get a simple name like "summer" without decorations.


 
 
einaros





PostPosted: Visual C++ General, __declspec(dllexport) required on function declaration in dll source code? Top

If you add extern "C" to the declaration in addition to __declspec(dllexport), the symbol will not be decorated.

 
 
georgeob





PostPosted: Visual C++ General, __declspec(dllexport) required on function declaration in dll source code? Top



 
 
Mike Danes





PostPosted: Visual C++ General, __declspec(dllexport) required on function declaration in dll source code? Top

extern "C" only prevents exporting the symbol using the C++ mangled name. It does not prevent decorating the name accodring to the stdcall convention.
 
 
Mike Danes





PostPosted: Visual C++ General, __declspec(dllexport) required on function declaration in dll source code? Top

See the other thread for a response:

http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=1021013&SiteID=1


 
 
ariff_multi





PostPosted: Visual C++ General, __declspec(dllexport) required on function declaration in dll source code? Top

may i have the full example the coding using __declspec.. in c++