CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    May 2000
    Location
    Indore (MP) INDIA.
    Posts
    356

    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)() ;

  2. #2
    Join Date
    Apr 1999
    Posts
    27,449

    Re: Application crash and use of mixed calling conventions ...

    Quote Originally Posted by VipulPathak View Post
    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

  3. #3
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,633

    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

  4. #4
    Join Date
    May 2000
    Location
    Indore (MP) INDIA.
    Posts
    356

    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)() ;

  5. #5
    Join Date
    Apr 2008
    Posts
    725

    Re: Application crash and use of mixed calling conventions ...

    Quote Originally Posted by VipulPathak View Post
    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
  •  





Click Here to Expand Forum to Full Width

Featured