Re: Mixed stdcall and cdecl code
From: Chuck Walbourn [MSFT] (chuckw_at_online.microsoft.com)
Date: 10/20/04
- Next message: Greg Ellis: "Re: VMR9 How to grab audio sample data"
- Previous message: Jeremy Noring: "Re: graphedit and code generation"
- In reply to: Iain: "Re: Mixed stdcall and cdecl code"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 20 Oct 2004 16:15:00 -0700
>> I'm writing a DirectShow capture filter, which requires the stdcall
>> calling
>> convention. I link to a 3rd party static library that apparently uses the
>> cdecl calling convention, because I was getting "unresolved external
>> symbol"
>> errors from the linker until I changed my project settings from stdcall
>> to
>> cdecl. The 3rd party did not explicitly declare a calling convention in
>> their headers. All of my COM interface implementations are declared with
>> STDMETHODIMP, so they use the stdcall convention, but simple overrides of
>> methods defined in the DirectShow BaseClasses library do not explicitly
>> declare the calling convention. I do not get any linker errors after
>> changing the project calling convention from stdcall to cdecl. Am I safe
>> to
>> proceed, or am I likely to have stack problems unless I explicitly
>> declare
>> all of my methods as stdcall? Is the runtime able to resolve virtual
>> functions if my project default is cdecl but the base class (from
>> BaseClasses lib) is stdcall?
> THere may be some pragma or define you can set before including the
> library
> header that indicates it is a stdcall. Or whatever.
>
The only way to resolve this is to edit the 3rd party header files and
explicitly list the calling convention for each routine. There isn't a
syntax for doing this as a 'wrapper' around the header. You should also
inform the 3rd party library provider that they should fix this in their
version of the headers. It is 'bad form' to use a different calling
convention and not mark the routines.
-- Chuck Walbourn SDE, Windows Gaming & Graphics This posting is provided "AS IS" with no warranties, and confers no rights.
- Next message: Greg Ellis: "Re: VMR9 How to grab audio sample data"
- Previous message: Jeremy Noring: "Re: graphedit and code generation"
- In reply to: Iain: "Re: Mixed stdcall and cdecl code"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|