From 4538808028686465174
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,bb04047befc790b4
X-Google-Attributes: gidf78e5,public
X-Google-ArrivalTime: 2001-02-23 11:56:04 PST
Return-Path: <devnull@stump.algebra.com>
X-Authentication-Warning: mulga.cs.mu.OZ.AU: fjh set sender to devnull@stump.algebra.com using -f
Path: supernews.google.com!sn-xit-03!supernews.com!logbridge.uoregon.edu!newsfeed.stanford.edu!comp-std-cpp-robomod!not-for-mail
X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov)
From: MikeAlpha@NoSpam_csi.com (Martin Aupperle)
Newsgroups: comp.std.c++
Subject: Re: empty parameter list and extern "C"
Organization: Nikoma Mediaworks GmbH
Message-ID: <3a968230.533654664@news.nikoma.de>
References: <3a91a017.213629713@news.nikoma.de> <h9f99tc98a3gp6q4a2e5n47imt44fr8b5k@4ax.com>
X-Trace: news.nikoma.de 982944528 59884 213.54.113.252 (23 Feb 2001 16:08:48 GMT)
X-Complaints-To: abuse@nikoma.de
NNTP-Posting-Date: Fri, 23 Feb 2001 16:08:48 +0000 (UTC)
X-Newsreader: Forte Free Agent 1.21/32.243
Approved: Fergus Henderson <fjh@cs.mu.oz.au>, moderator of comp.std.c++
Date: Fri, 23 Feb 2001 13:52:36 CST
Lines: 66
Xref: supernews.google.com comp.std.c++:3766

On Thu, 22 Feb 2001 19:32:10 GMT, Jack Klein <jackklein@spamcop.net>
wrote:

>
>Understand that C++ does not guarantee interoperability with code
>compiled by a C compiler, or even by the same compiler in its C mode,
>if it has one.  The intent is to provide this capability if possible,
>but all that extern "C" is guaranteed to do is provide C linkage. 
>
I understand. So, please look at the following scenario:

1.)  I have a very old and mean C-Library (i.e. one that is compiled
with a C-compiler). It exposes a header file foo.h that declares a
function f like this:

	void f();

2.) Since it is a C-Library, I conclude that f can (syntactically) be
called with arbitrary arguments. Any C-Program that includes foo.h
should be able to do so.

3.) But I have a C++ program and want to use the library. Therefore I
say

	extern "C" 
	{
	  #include "foo.h"
	}
	
Now I have a function  f declared and can use it. BUT NOT with
arbitrary parameters!

4.) It is also not possible to declare f myself, as for example like
this

	extern "C" void f(...);

because then I cannot include foo.h with all the rest of the functions
any more. (Overloading is not possible with extern "C" - that's
understandable)..


So - what is the solution? I probably can introduce a cpp-file that
does nothing but declare f like in 4.), define another function f2
like

	void f2(...);

that does nothing except calling f. But will the parameters be
correctly passed? I think not necessarily, because f2 has c++ linkage
and f has c linkage.


------------------------------------------------
Martin Aupperle 
MikeAlpha@NoSpam_csi.com
(remove NoSpam_)
------------------------------------------------

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



