This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

c++/907: __attribute__((stdcall)) does not affect C++ Methods, rendering __attribute__(com_interface) nonsensical.

>Number:         907
>Category:       c++
>Synopsis:       __attribute__((stdcall))  does not affect C++ Methods, rendering __attribute__(com_interface) nonsensical.
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Nov 27 10:36:00 PST 2000
>Originator:     Robin Davies (
>Release:        MINGW 2.95.2
Trying to implement COM-compatible interfaces with mingw32 2.95.2. The declaration __attribute__(com_interface) works correctly, laying out the vtable in correct form; however, COM uses pascal-style calls (arguments pushed left-to-right, callee pops return address). When making COM calls, functions need to be declared __stdcall in the Win32 environment, which expands to __attribute__(__stdcall__). GCC accepts the declaration, but compiles the code to use C calling convention instead.

Compile Options: -fvtable-thunks 

#include <objbase.h>

	HRESULT __attribute__((stdcall)) QueryInterface(const IID&, void **) { 
            return E_FAIL;         }
	ULONG __attribute__((stdcall)) AddRef() { return 0; }
	ULONG __attribute__((stdcall)) Release() { return 0; }



A::AddRef assembler output should return with 
"ret 4", not "ret".



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]