Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uunet!cs.utexas.edu!uwm.edu!lll-winken!arisia!sgi!shinobu!odin!delrey!shap From: shap@delrey.sgi.com (Jonathan Shapiro) Newsgroups: comp.lang.c++ Subject: Re: C++ masquerading as C ... How? Message-ID: <2541@odin.SGI.COM> Date: 7 Jan 90 20:59:41 GMT References: <6170011@hpindda.HP.COM> Sender: news@odin.SGI.COM Organization: Silicon Graphics, Inc., Mountain View, CA Lines: 42 In article <6170011@hpindda.HP.COM> hardin@hpindda.HP.COM (John Hardin) writes: > Can someone tell me how to make a separately compiled function > written in C++ look like a normal C function to a program written in > C? > >John Hardin >Hewlett Packard, Information Networks Division >hardin%hpindgi@hplabs.hp.com >---------------------------- There are a couple of strategies. 1. You can declare the function using extern "C": extern "C" int froboz(int); int froboz(int i) { return i; } This has the disadvantage that C++ code that uses it won't get typesafe linkage. 2. You can declare the function with a slightly different name for c: extern "C" int c_froboz(int); int froboz(int i) // c++ version { return i; } int c_froboz(int i) { return froboz(i); } // C version Advantage is typesafe linkage for C, but disadvantage is the name is different. Hope it helps Jonathan S. Shapiro Silicon Graphics, Inc.