From -2518250008113207864
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:04 PST
Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!news.tele.dk!small.news.tele.dk!212.74.64.35!colt.net!dispose.news.demon.net!news.demon.co.uk!demon!mail2news.demon.co.uk!not-for-mail
From: Francis Glassborow <francis.glassborow@ntlworld.com>
Newsgroups: comp.std.c++
Subject: Re: extern "C" -- what is the intent?
Date: Mon, 13 Aug 2001 03:24:43 GMT
Organization: Southfield Microcomputer SS
Approved: Fergus Henderson <fjh@cs.mu.oz.au>, moderator of comp.std.c++
Message-ID: <KZEHKGBgCqd7EwcR@ntlworld.com>
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>
Reply-To: Francis Glassborow <francisG@robinton.demon.co.uk>
X-Trace: mail2news.demon.co.uk 997673180 mail2news:567 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
X-Newsreader: Turnpike Integrated Version 5.00 U <TilyaeicE$WmMOP9F8P4$y3lmP>
Lines: 33
Xref: archiver1.google.com comp.std.c++:6950

In article <remove.haberg-1108011937150001@du131-226.ppp.su-
anst.tninet.se>, Hans Aberg <remove.haberg@matematik.su.se> writes
>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.
That maybe an expression of intent, but 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);

nor, if foo is defined and compiled with a C compiler, that your C++
code can call it successfully. However, it is just about certain that
the code will not link successfully if the declaration does not have
extern "C" linkage.

Many people expect too much from linkage specifications. They are
necessary but not sufficient.


Francis Glassborow      ACCU
64 Southfield Rd
Oxford OX4 1PA          +44(0)1865 246490
All opinions are mine and do not represent those of any organisation

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



