TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: Paul Edwards
from: Mario Semo
date: 1996-01-21 04:04:36
subject: callconv.txt

Hello Paul,

On Jan 11 19:56 96, Paul Edwards of 3:711/934.9 wrote:

 PE> Note - this document documents my current understanding.  


 PE> CALLING CONVENTIONS IN OS/2

 PE> CSET
 PE> _System gets the standard calling convention
 PE> _Optlink gets a CSET-specific calling convention.  Their C
 PE> library is all compiled with this calling convention


=========================================================================
   Date: 09-10-93  15:45                Message #: 733           02490020
   From: BIGBILL at TOROLAB6ÿ           Status: PUBLIC
     To: Magnus Lovkvist                Ref #:  716
Subject: Threads And C++                Conf: C-Set/2 Cust (14)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

When you declare a function in C++ without specifying a linkage, then it gets
C++ linkage.  C++ linkage means that its name is mangled so that it can be
overloaded and it follows the same calling convention as OPTLINK.  However, C++
linkage and OPTLINK linkage are NOT the same.

So, to answer your questions, OPTLINK is not the default, C++ is. That's why
you had to add the _Optlink keyword to sample02.  Our compiler doesn't allow
member functions with _Optlink linkage, so you can't use member functions in
this case.  The ICLUI class has an IThread class which encapsulates this kind
of stuff, why don't you take a look at that?  I'll take another look at
this stuff, but I can't provide any promises at this point.

Bill Sarantakos                     C Set ++ Development - C++ Compiler

=========================================================================
   Date: 09-13-93  13:44                Message #: 751           02490020
   From: BIGBILL at TOROLAB6ÿ           Status: PUBLIC
     To: DEV2081 at OS2CUST             Ref #:  738
Subject: Threads And C++                Conf: C-Set/2 Cust (14)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
I guess its just a difference in semantics I guess.  I consider the name
mapping as part of the linkage convention.  But to be explicit,
here is a summary.

Linkage        Name Mapping          Linkage
----------     ------------          -------
C++            f(x) = mangle(x)      register/stack, R-L, ...
OPTLINK        f(x) = x              register/stack, R-L, ...
SYSTEM         f(x) = x              stack, R-L, ...
FAR16 PASCAL   f(x) = strupr(x)      stack, L-R, ...
FAR16 CDECL    f(x) = strcat("_", x) stack, R-L, ...
FAR16 FASTCALL f(x) = strcat("{at}", x) register/stack, R-L, ...

where R-L means parameters are pushed right-to-left and L-R, left-to-
right.

Bill Sarantakos                     C Set ++ Development - C++ Compiler

 WARPED!, Mario

--- Msgedsq/2 2.2e
* Origin: LC/32 Development Team-Vienna-Austria (2:310/14.11)
SEEN-BY: 50/99 270/101 620/243 711/401 409 410 413 430 808 809 934 955
SEEN-BY: 712/407 515 517 628 713/888 800/1 7877/2809
@PATH: 310/14 1 24/999 2/777 396/1 270/101 712/515 711/808 809 934

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.