From 9154434319198383355
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 109fba,a5f5b2eff7f20a08
X-Google-Attributes: gid109fba,public
X-Google-Thread: f78e5,8b7078226bb8aefc,start
X-Google-Attributes: gidf78e5,public
X-Google-ArrivalTime: 1994-05-23 12:59:56 PST
Newsgroups: comp.lang.c++,comp.std.c++
Path: bga.com!news.sprintlink.net!news.dorsai.org!news.ilx.com!psinntp!psinntp!ses.com!jamshid
From: jamshid@ses.com (Jamshid Afshar)
Subject: C vs C++ calling sequence (was Re: cast member funct ptr to pfn?)
Message-ID: <Cq8pJn.47F@ses.com>
Followup-To: comp.std.c++
Sender: usenet@ses.com
Nntp-Posting-Host: castro
Organization: SES, Inc., Austin, TX, USA
References: <2pp68l$a1d@sirius.cs.pdx.edu> <CpCIEK.2IE@microsoft.com> <KANZE.94May9193709@slsvhdt.us-es.sel.de>
Date: Mon, 23 May 1994 05:21:23 GMT
Lines: 36
Xref: bga.com comp.lang.c++:16360 comp.std.c++:2422

Redirected to comp.std.c++.

In article <KANZE.94May9193709@slsvhdt.us-es.sel.de>,
James Kanze <kanze@us-es.sel.de> wrote:
>In article <CpCIEK.2IE@microsoft.com> jimad@microsoft.com (Jim Adcock)
>writes:
|
>|> *Static* member functions can be cast to "C" function type, while allowing
>|> you to keep the function name in the class namespace.
>
>For some implementations, as has been pointed out in another thread.
>In particular, I would expect that good compilers for 80x86 will not
>support this.  (Typically, C functions will require the caller to do
>stack clean-up, whereas C++ functions will have the callee do it.)

I missed that thread, but there is no difference between ANSI C and
C++ in this regard.  It is illegal in ANSI C to call a function with a
different number or type of arguments from the parameters declared in
the function definition.  ANSI C requires that functions taking
variable arguments be prototyped before use using the ellipses
notation.

K&R1 didn't have the ellipses, function prototypes, or
<vararg.h>/<stdarg.h>, but it was hazy about the subject and stressed
that there is no portable way to write a function taking a variable
number of arguments: "printf, the most common C function with a
variable number of arguments, [...] is also non-portable and must be
modified for different environments".

Point being, there's nothing stopping a C compiler vendor from using
more efficient calling sequences or even type-safe linkage except
their users who have a lot of broken code (at least in the eyes of
ANSI C).

Jamshid Afshar
jamshid@ses.com


