473,385 Members | 1,347 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Who define __cdecl, __stdcall, etc...

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

Jun 5 '06 #1
5 5784
kwijibo28 wrote:
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.

--
Mike Smith
Jun 5 '06 #2
Mike Smith wrote:
kwijibo28 wrote:
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.


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.

Jun 5 '06 #3

Mike Smith wrote:
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

Jun 6 '06 #4
Markus Schoder wrote:
Mike Smith wrote:
kwijibo28 wrote:
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.


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".

--
Mike Smith
Jun 6 '06 #5
mylea
3
when a dll written by MS is used in BCB, there need a convertion. for example,a dll named "Test.dll" is compiled by MS,and there is a file named "Test.lib". you should use BCB tool named "implib.exe". its location is "$(BCBDir)/bin". just follow the steps.
implib.exe Test.lib Test.dll
then,a new lib file is created,and it can be used in your BCB project.
when you declare the function defined in Test.dll, you should do like this:
#define IMPORT __declspec(dllimport)
IMPORT void __stdcall Test();
the function Test() is just an example.
Jun 7 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: pawel | last post by:
Hi! I have a .dll library, with some exported function, which looks something like this: extern "C" { int exported_f (int (__cdecl *callback) (int a, int b)) ; } now, I want to invoke this...
2
by: Ed | last post by:
Suppose I want a function a pointer to which is going to be passed to another function to use __stdcall conventions. That is, I want the call to cbFunc() in tryCB3() to be compiled for __stdcall...
3
by: vinu_gt | last post by:
Hi All, I had a question about stdcall and cdecl calling convention related to Visual Studio 6.0 I have a console project and in Project->setting->C++->Code Generation The "calling...
4
by: thinktwice | last post by:
i have just made a test project :(win32 console) //file : func.h #ifndef _FUNC_H_ #define _FUNC_H_ void func1() { return; };
2
by: Pugal | last post by:
hi what is the difference between _stdcall and __cdecl, is the stack release issue much important.. and why other languages like java are not worrying about these things.. any idea.. -Pugal
2
by: Virtual_X | last post by:
i am beginner to c++ when i open the file "stdio.h" i have found the line _CRTIMP int __cdecl remove (const char*); and similar lines to it so what's "_CRTIMP" and "__cdecl"
7
by: =?gb2312?B?wfXquw==?= | last post by:
Hi folks, I am running into with such a question when I tried to declare and define a friend template function in a template class, here is the code snippet: #include <iostream> using...
54
by: Bartc | last post by:
I'm mixing C and ASM, and for calling ASM from C, I just happened to use the __stdcall convention (using C convention is not practical for other reasons). But, __stdcall seems to assume that...
6
by: Ole Nielsby | last post by:
VC has a __cdecl specifier which allows functions and methods to be called with varying parameter count. (I understand this is the default for functions in general but in VC, instances use...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.