From 8055230441152417982
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: f78e5,ea96cc047f6a22cc
X-Google-Attributes: gidf78e5,public
X-Google-ArrivalTime: 2001-08-27 15:29:01 PST
Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!dispose.news.demon.net!news.demon.co.uk!demon!mail2news.demon.co.uk!not-for-mail
From: joerg.barfurth@attglobal.net (Joerg Barfurth)
Newsgroups: comp.std.c++
Subject: Re: extern "C" -- what is the intent?
Date: Mon, 27 Aug 2001 22:28:25 GMT
Organization: My beloved Family
Approved: Fergus Henderson <fjh@cs.mu.oz.au>, moderator of comp.std.c++
Message-ID: <1eytm7g.12quiy6u3s1qwN%joerg.barfurth@attglobal.net>
References: <090820010209154805%BobbySchmidt@mac.com> <remove.haberg-1008011309410001@du132-226.ppp.su-anst.tninet.se> <rjRvUrB1oAd7Ew7$@ntlworld.com> <remove.haberg-1008012124210001@du136-226.ppp.su-anst.tninet.se> <v0ceBIAA0Hd7EwKT@ntlworld.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> <1eys049.1mtaactofnng2N%joerg.barfurth@attglobal.net> <remove.haberg-2708011912260001@du132-226.ppp.su-anst.tninet.se>
X-Trace: mail2news.demon.co.uk 998951310 mail2news:5896 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)
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
User-Agent: MacSOUP/D-2.4.6 (unregistered for 412 days)
Content-Transfer-Encoding: quoted-printable
X-MIME-Autoconverted: from 8bit to quoted-printable by mulga.cs.mu.OZ.AU id IAA00496
Lines: 76
Xref: archiver1.google.com comp.std.c++:7203

Hans Aberg <remove.haberg@matematik.su.se> wrote:

> >>   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 main point is that=20
>   extern "C++" int
> and
>   extern "C" int
> need not anymore have the same underlying binary structure.

Even if a language linkage does allow linking to code written in a given
language, that does not mean that C++-declarations under that language
linkage are textually equivalent to declarations of the same entity in
the other language.

Thus in=20
  extern "C" int foo();

'int' is the C++-Type int and is not necessarily identical to type int
in all linkable C implementations. Thus the same function may need to be
declared as=20
  long foo(void);

in C.

This may seem confusing for C, but it becomes clear when you consider
that

  extern "Pascal"=20
  procedure foo(i : Integer) forward;

is not well-formed C++, while a C++ implementation might define that

  extern "Pascal" void foo(short);

can be used to declare and call in C++ code a function that is defined
in some Pascal dialect as

  procedure foo( i : Integer ) BEGIN { ... } END

Thus you also don't need any 'conversion operators' to define a
conversion between homonymous types having different binary
representations. A C++ declaration is only concerned with C++ types,
even under a language linkage that is not 'extern "C++"'. Thus we
needn't require builtin support for type 'Boolean' to link to Pascal
code.

All that is needed is a mapping from one type system to the other which
allows finding the corresponding declaration in the other language. This
means that there needn't be any code or operational definitions, but
only descriptions of correspondence. If there only are matches for a
subset of the type system(s), then that means that only for declarations
from that subset linkage can be achieved.

Of course there isn't anything to prevent builtin conversions either.
Maybe a linker could automatically build stubs that do type conversions
and adjusts calling conventions. But I don't think that could be
considered a core part of what language linkage is intende for.

Regards, J=F6rg

--=20
J=F6rg Barfurth                         joerg.barfurth@attglobal.net
<<<<<<<<<<<<< using std::disclaimer;  <<<<<<<<<<<<<<<<<<<<<<<<<<<<
Software Developer                    http://www.OpenOffice.org
StarOffice Configuration              http://www.sun.com/staroffice

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



