Application crash and use of mixed calling conventions ...
Hi Everyone,
I have a DLL in my application that exports 5 functions. This DLL internally uses a few C++ classes and finally provide the functionality to DLL client applications by means of those exposed 5 functions.
The application has started crashing when the DLL started using C++ classes to implement functionality. The code inside C++ classes, when added a simple C code, then the crash doesn't happen.
I am aware of calling conventions, like- __stdcall and __cdecl etc. But not aware, how to use use both __cdecl and __stdcall in the same DLL.
Any suggestion from anyone ?
Any help is greatly appreciated.
Re: Application crash and use of mixed calling conventions ...
Quote:
Originally Posted by
VipulPathak
I am aware of calling conventions, like- __stdcall and __cdecl etc. But not aware, how to use use both __cdecl and __stdcall in the same DLL.
You explicitly specify "__cdecl" or "__stdcall" when declaring each function in the DLL.
Regards,
Paul McKenzie
Re: Application crash and use of mixed calling conventions ...
Quote:
not aware, how to use use both __cdecl and __stdcall in the same DLL
There's no any magic in that, you just need to specify the convention explicitly.
Re: Application crash and use of mixed calling conventions ...
Thanks Paul and Igor,
Could you please give an example.
Consider the following code snippet as an example:
Code:
BOOL WINAPI GetServerInfo(OUT LPTSTR *lpInfo)
{
. . .
. . .
string sServerIpAddress = SysUtils::GetServerAddress() ;
string sServerName = SysUtils::GetThisComputerName() ;
. . .
. . .
{
ProgressLog objProgressLog( sCodeProgessLogFileName ) ;
objProgressLog.AddInfoLine( TEXT("Returning IP and Name ...") ) ;
}
}
Here ProgressLog and SysUtils are C++ classes. GetServerInfo() is a DLL function.
Did you meant that I should put __cdecl in fron of every method in Header files of ProgressLog and SysUtils ?
Should I also put __cdecl in CPP files ?
Please elaborate.
Re: Application crash and use of mixed calling conventions ...
Quote:
Originally Posted by
VipulPathak
Thanks Paul and Igor,
Could you please give an example.
Consider the following code snippet as an example:
Code:
BOOL WINAPI GetServerInfo(OUT LPTSTR *lpInfo)
{
. . .
. . .
string sServerIpAddress = SysUtils::GetServerAddress() ;
string sServerName = SysUtils::GetThisComputerName() ;
. . .
. . .
{
ProgressLog objProgressLog( sCodeProgessLogFileName ) ;
objProgressLog.AddInfoLine( TEXT("Returning IP and Name ...") ) ;
}
}
Here ProgressLog and SysUtils are C++ classes. GetServerInfo() is a DLL function.
Did you meant that I should put __cdecl in fron of every method in Header files of ProgressLog and SysUtils ?
Should I also put __cdecl in CPP files ?
Please elaborate.
http://lmgtfy.com/?q=calling+convent...on+declaration