Who define __cdecl, __stdcall, etc...

K

kwijibo28

Hi all,

I was wondering if there is a standard definition for the calling
convention like __cdecl and __stdcall. I've search the c++ standard
document and there is no mention of __cdecl or __stdcall. I'm not very
surprise, for the committe, how to pass argument from a function to an
other, must be an implementation detail left to the compiler vendor.

But since in real life people write library which are build with a
compiler and use possibly by another compiler, compiler vendor must
agree on a common definition. I guess that definition should also
specify how to decorate function name according to a calling
convention.

I'm asking this question because recently I've build a dll with a MS
compiler and my client had a borland and we've found out that both
compiler don't agree on function decoration for __cdecl and __stdcall.

Thanks
Kwijibo28
 
M

Mike Smith

kwijibo28 said:
Hi all,

I was wondering if there is a standard definition for the calling
convention like __cdecl and __stdcall. I've search the c++ standard
document and there is no mention of __cdecl or __stdcall. I'm not very
surprise, for the committe, how to pass argument from a function to an
other, must be an implementation detail left to the compiler vendor.

But since in real life people write library which are build with a
compiler and use possibly by another compiler, compiler vendor must
agree on a common definition. I guess that definition should also
specify how to decorate function name according to a calling
convention.

I'm asking this question because recently I've build a dll with a MS
compiler and my client had a borland and we've found out that both
compiler don't agree on function decoration for __cdecl and __stdcall.

Neither of those vendor-specific directives have anything to do with C++
name-mangling - they refer instead to argument passing and stack
cleanup. Sadly, no two vendors seem to agree on a name-mangling scheme,
which leaves us relying on COM, CORBA, or plain-jane C for interoperability.
 
M

Markus Schoder

Mike said:
Neither of those vendor-specific directives have anything to do with C++
name-mangling - they refer instead to argument passing and stack
cleanup. Sadly, no two vendors seem to agree on a name-mangling scheme,
which leaves us relying on COM, CORBA, or plain-jane C for interoperability.

Vendors are well adviced to choose different name-mangling schemes
_unless_ their compilers are truely binary compatible. This includes
not only function calling conventions but at least the standard library
implementation, virtual tables, exception handling and RTTI. This would
indeed tie the two implementations very closely together.
 
K

kwijibo28

Mike said:
Neither of those vendor-specific directives have anything to do with C++
name-mangling - they refer instead to argument passing and stack
cleanup. Sadly, no two vendors seem to agree on a name-mangling scheme,
which leaves us relying on COM, CORBA, or plain-jane C for interoperability.

Alright thanks for the info,

I will try to provide a plain C interface for my dll then. And I will
continue my investigation in a C forum. (I don't want to get flame
because I'm getting off-topic!)

Kwijibo28
 
M

Mike Smith

Markus said:
Vendors are well adviced to choose different name-mangling schemes
_unless_ their compilers are truely binary compatible. This includes
not only function calling conventions but at least the standard library
implementation, virtual tables, exception handling and RTTI. This would
indeed tie the two implementations very closely together.

Well, yes. What I should have said was "sadly, on most platforms, there
is no commonly accepted C++ ABI that allows interoperability between
compilers".
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top