From 7547944622302828985
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,ea96cc047f6a22cc
X-Google-Attributes: gidf78e5,public
X-Google-ArrivalTime: 2001-08-12 20:27:07 PST
Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!newsfeeds.belnet.be!news.belnet.be!colt.net!dispose.news.demon.net!news.demon.co.uk!demon!mail2news.demon.co.uk!not-for-mail
From: comeau@panix.com (Greg Comeau)
Newsgroups: comp.std.c++
Subject: Re: extern "C" -- what is the intent?
Date: Mon, 13 Aug 2001 03:24:43 GMT
Organization: Comeau Computing; http://www.comeaucomputing.com
Approved: Fergus Henderson <fjh@cs.mu.oz.au>, moderator of comp.std.c++
Message-ID: <9l62tf$c2g$1@panix3.panix.com>
References: <090820010209154805%BobbySchmidt@mac.com> <remove.haberg-1008012124210001@du136-226.ppp.su-anst.tninet.se> <v0ceBIAA0Hd7EwKT@ntlworld.com> <remove.haberg-1108011937150001@du131-226.ppp.su-anst.tninet.se>
Reply-To: comeau@comeaucomputing.com
X-Trace: mail2news.demon.co.uk 997673197 mail2news:571 mail2news mail2news.demon.co.uk
X-Complaints-To: abuse@demon.net
X-Mail2News-Path: news.demon.net!mulga.cs.mu.oz.au
X-Authentication-Warning: mulga.cs.mu.OZ.AU: fjh set sender to devnull@stump.algebra.com using -f
X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov)
Lines: 51
Xref: archiver1.google.com comp.std.c++:6951

In article <remove.haberg-1108011937150001@du131-226.ppp.su-anst.tninet.se>,
Hans Aberg <remove.haberg@matematik.su.se> wrote:
>In article <v0ceBIAA0Hd7EwKT@ntlworld.com>, Francis Glassborow
><francisG@robinton.demon.co.uk> wrote:
>>extern "C" void foo(mytype);
>>
>>How does it matter what type mytype is? Unlike function, we do not
>>overload types so as long as mytype has a unique ID, that is the end of
>>the story. Of course a C program cannot pass arguments to foo unless it
>>has a compatible type but that is quite different and not the concern of
>>the linker. The linker only has to find object code from compiling a
>>function definition for foo. If the argument does not match, it is the
>>compilers job to call it out.
>
>I got the impression that having extern "C" linkage meant that C code
>could link to it. But here you seem to say that is not really the case;
>instead having linkage to the C language may just as well mean that one
>can link to it.

I think that Francis may have delineated compiler and linker
too strongly.  Anyway, I think the operative words are "could"
and "can" rather than "should" or "must".

>I am well aware of that one can mix types in a compiler if relies on the
>underlying binary structure. For example, my C compiler can link to
>Pascal. It uses the convention that Pascal strings correspond to C
>unsigned char[256]. But the question is whether
>  extern "Pascal" void f(unsigned char*);
>is really linkage to the (standard) Pascal language, as a Pascal compiler
>not really can link to it: One needs a special Pascal compiler aware of
>these conventions.

IMO, it gets fuzzy, but the thing is that the liberty for
it to "do the right thing" does exist.  I'm not sure what you
mean by "special Pascal compiler" since usually so-called
"LanguageX calling convention" is a slippery beast in itself,
and so one usually is talking about calling conventions
for a specific release of a specific compiler (though clearly
some convention are popular).
-- 
Greg Comeau                 Countdown to "export": December 1, 2001
Comeau C/C++ ONLINE ==>     http://www.comeaucomputing.com/tryitout

Tasty C99/C++ Combo: Dinkumware libs + Comeau Compilers == WOW!!!

---
[ 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                ]



