From 2620670065130348719
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,bb04047befc790b4
X-Google-Attributes: gidf78e5,public
X-Google-ArrivalTime: 2001-02-21 13:23:09 PST
Path: supernews.google.com!sn-xit-02!supernews.com!news.tele.dk!194.176.220.129!newsfeed.icl.net!dispose.news.demon.net!news.demon.co.uk!demon!mail2news.demon.co.uk!not-for-mail
From: Ron Natalie <ron@spamcop.net>
Newsgroups: comp.std.c++
Subject: Re: empty parameter list and extern "C"
Date: Wed, 21 Feb 2001 21:21:42 GMT
Organization: Sensor Systems
Approved: Fergus Henderson <fjh@cs.mu.oz.au>, moderator of comp.std.c++
Message-ID: <3A942508.F2FC0348@spamcop.net>
References: <3a91a017.213629713@news.nikoma.de>
X-Trace: mail2news.demon.co.uk 982790520 mail2news:9751 mail2news mail2news.demon.co.uk
X-Complaints-To: abuse@demon.net
X-Mail2News-Path: news.demon.net!mulga.cs.mu.oz.au
X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov)
X-Authentication-Warning: backdraft.briar.org: smap set sender to <news@mencken.net.nih.gov> using -f
X-Accept-Language: en
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
NNTP-Posting-Date: Wed, 21 Feb 2001 15:30:03 EST
Lines: 44
Xref: supernews.google.com comp.std.c++:3734



Martin Aupperle wrote:

> I hope that I remember right that a function with the signature
> 
>         void f();
> 
> and compiled under a C-compiler can be called with arbitrary
> arguments.

Yes, C is loosy goosy.  Note however that the absence of the
arguments means that certain promotions happen that wouldn't
if you had explicitly declared them.

> But when I declare
> 
>         extern "C" void f();
> 
> and compile under a C++ compiler, I cannot call f with arguments.

That is true.  
> 
> Is it correct that an empty argument list means "no arguments" even if
> we compile against an implementation that allows it ( here, the
> implementation of f is likely to be in a C-Module that must make no
> assumptions about the arguments and therefore can be called with
> arbitrary ones) ?

extern "C" doesn't change the language, just the linkage issues (how
functions get called and how the names are managed).   C++ absolutely
requires a full declaration (prototype in C terms) of the function
before it can be called (unless you're using varargs).  It's the caller
who has to support it not the definition of the function.  If you define
the function extern "C" in C++, your C modules are still free to call it
without an explicit declaration/prototype.

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]
[ Note that the FAQ URL has changed!  Please update your bookmarks.     ]



