From 324021309977899504
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,ea96cc047f6a22cc
X-Google-Attributes: gidf78e5,public
X-Google-ArrivalTime: 2001-08-13 11:35:01 PST
Path: archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!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 18:32:40 GMT
Organization: Comeau Computing; http://www.comeaucomputing.com
Approved: Fergus Henderson <fjh@cs.mu.oz.au>, moderator of comp.std.c++
Message-ID: <9l8qvc$7ig$1@panix3.panix.com>
References: <090820010209154805%BobbySchmidt@mac.com> <remove.haberg-1108011937150001@du131-226.ppp.su-anst.tninet.se> <9l62tf$c2g$1@panix3.panix.com> <remove.haberg-1308011259440001@du132-226.ppp.su-anst.tninet.se>
Reply-To: comeau@comeaucomputing.com
X-Trace: mail2news.demon.co.uk 997727658 mail2news:6796 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: 82
Xref: archiver1.google.com comp.std.c++:6965

In article <remove.haberg-1308011259440001@du132-226.ppp.su-anst.tninet.se>,
Hans Aberg <remove.haberg@matematik.su.se> wrote:
>In article <9l62tf$c2g$1@panix3.panix.com>, comeau@comeaucomputing.com wrote:
>>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).
>
>I am disregarding the fact that the compilers always must somehow be tuned
>together.

Ok (it seem you want to go somewhere with this).

>Then there is the question how much the linker should check for the
>accuracy of the linking. In the example I gave, I figure that as Pascal
>does not have name overloading, perhaps the linker would just be handed
>down a function name, assuming that the binary argument is correct. Then
>there would be no problems with
>  extern "Pascal" void f(unsigned char*);
>as the argument is untyped by the time the linker sees the function a
>Pascal type.

If I understand what you've said, yes, I think that's possible.

>In article <KZEHKGBgCqd7EwcR@ntlworld.com>, Francis Glassborow
><francisG@robinton.demon.co.uk> wrote:
>>... the C++ compiler has no idea
>>what will link to C. That is an issue for the programmer, knowing what
>>the compilers require. There is no reason that even this will link to C
>>object code:
>>
>>extern "C" int foo(int, int);
>
>It seems me that the standard is flawed, as what is called "linkage to the
>language X" does not mean that one can actually link to code written in
>the language X. There are two ways around this: One is to change the name
>to say "pseudo-linkage", so that it becomes explicitly clear that it is
>merely a way for the C++ compiler can attach language labels onto the code
>so that the linker might use it for linking.

There probably is a terminology issue here, but I don't think that
means (or at least has to mean) it is flawed.  Either way the
semantics (or lack thereof) need to be described.  Anyway, I agree,
there often seem to be confusion in the part of the standard.

>Another way would be to strengthen the requirement so that linkage to the
>language X actually means that one can link code to that language (even
>though, clearly, it still depends on the two compiler being tuned
>together). Then
>  extern "C" short foo(int);
>is not legal unless one has specified conversion operators
>  extern "C++" int -> extern "C" int
>  extern "C" short -> extern "C++" short
>
>The spin off if forcing such conversion operators to be explicit in the
>language is that the types of the different languages need not be tuned
>together: In the example, it does not matter anymore that the integral
>types of the two different languages are the same. One could also go a
>step further, and use it to tune together different compilers of the same
>language, that is, if it is somehow possible to indicate in the "extern"
>declaration the name of the compiler.

A problem that I have with this is that to link to Language X can't
actually mean to link to Language X because often Language X doesn't
describe what linking to it actually means.  So it would seem
wrong for Standard C++ to do so.  I mean, how could it?
(I think you may actually say so above, but I didn't get it.)
-- 
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                ]



