PaulH
PaulH

Reputation: 7843

the use of __stdcall and __cdecl in Windows CE DLLs

I have a Visual Studio 2008 C++03 application for Windows CE 6.0 x86. I'm having an issue where invoking a function from a DLL is causing an access violation exception, but only in debug mode.

// DLL header
extern "C" BOOL __stdcall Foo( const wchar_t*, const wchar_t*, wchar_t*, unsigned long );

// program
#include "foo.h"
#pragma comment( lib, "foo.lib" )
int main()
{
    wchar_t f[ 100 ];
    Foo( L"something", L"nothing", f, countof( f ) );    // access violation
    return 0;
}

I realize this could be caused by any number of different things, but I'm curious about the use of __stdcall in the DLL header. In Windows CE, the default (for windows APIs) is __cdecl. Why would this library use __stdcall? Could that have a detrimental effect?

Actually, why specify a calling convention at all?

Thanks

Upvotes: 1

Views: 885

Answers (1)

Rob Kennedy
Rob Kennedy

Reputation: 163247

In Windows CE, __stdcall is a macro that resolves to __cdecl. That is, they designate the same calling conventions. Your problem lies elsewhere. Use the debugger to investigate.

A calling convention might be specified because it needs to be specified for the desktop version of the DLL, and it's easier to keep the source code the same for both targets than to clutter it with conditional compilation that has no real effect.

Upvotes: 2

Related Questions