This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
c++/907: __attribute__((stdcall)) does not affect C++ Methods, rendering __attribute__(com_interface) nonsensical.
- To: gcc-gnats at gcc dot gnu dot org
- Subject: c++/907: __attribute__((stdcall)) does not affect C++ Methods, rendering __attribute__(com_interface) nonsensical.
- From: rerdavies at msn dot com
- Date: 27 Nov 2000 18:30:46 -0000
- Reply-To: rerdavies at msn dot com
>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
>Closed-Date:
>Last-Modified:
>Originator: Robin Davies (rerdavies@msn.com)
>Release: MINGW 2.95.2
>Organization:
>Environment:
Win32
>Description:
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.
e.g:
Compile Options: -fvtable-thunks
Source:
#include <objbase.h>
DECLARE_INTERFACE_(A,IUnknown) {
public:
HRESULT __attribute__((stdcall)) QueryInterface(const IID&, void **) {
return E_FAIL; }
ULONG __attribute__((stdcall)) AddRef() { return 0; }
ULONG __attribute__((stdcall)) Release() { return 0; }
};
Test:
A::AddRef assembler output should return with
"ret 4", not "ret".
>How-To-Repeat:
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted: