|
-
May 31st, 2010, 12:18 PM
#1
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.
(*Vipul)() ; 
-
May 31st, 2010, 12:24 PM
#2
Re: Application crash and use of mixed calling conventions ...
 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
-
May 31st, 2010, 12:25 PM
#3
Re: Application crash and use of mixed calling conventions ...
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.
Best regards,
Igor
-
May 31st, 2010, 01:07 PM
#4
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.
(*Vipul)() ; 
-
May 31st, 2010, 01:18 PM
#5
Re: Application crash and use of mixed calling conventions ...
 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
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
|