Here is an explaination of how I use it. I always use it with __declspec and don't have a problem. It does not affect the .DEF file -- actually the DEF file is not even needed when dllexport is used.
Ancient Dragon
Retired & Loving It
30,042 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,341
Is b.cpp the application program that is calling the exported function in a.cpp, which is in a dll ?
In b.cpp you need to declare the function as _dllimport.
// b.cpp is the application program
//
_delspec(_dllimport) void a();
void foo()
{
a();
}
Ancient Dragon
Retired & Loving It
30,042 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,341
>>From what I understand from MSDN, dllexport is supposed to substitute the export section in the .DEF file -
Your understanding is incorrect. What MSDN means is that you can export the function in one of two ways:use the __dllspec( __dllexport ) tags
add an entry into the .DEF file
The compiler does not make any entries into the .DEF file for you -- you have to do that yourself if you want them there.
Prototyping the function as you did in a.cpp is not sufficient. You have to add dllexport in the function itself
a.cpp
__dllspec( __dllexport ) void a()
{
// blabla
}
You can also export an entire c++ class
__dllspec( __dllexport) class MyClass
{
// blabla
}
Ancient Dragon
Retired & Loving It
30,042 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,341