linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Glynn Clements <glynn.clements@virgin.net>
To: Jamie Risk <jamie_risk@yahoo.ca>
Cc: linux-c-programming@vger.kernel.org
Subject: Re: integrating c code and c++ code
Date: Fri, 3 Jan 2003 03:49:41 +0000	[thread overview]
Message-ID: <15893.2133.819501.402598@cerise.nosuchdomain.co.uk> (raw)
In-Reply-To: <av1p1u$aog$1@main.gmane.org>


Jamie Risk wrote:

> It's also useful to surround your c code with "extern c { ... code ... }"
> when compiling c files with a cpp compiler. Doing so will avoid confusion
> when calling C routines compiled by a cpp compiler from C routines compiled
> by a C compiler (name mangling issues).

Using 'extern "C" ...' only forces C linkage; the code is still
compiled according to the rules of C++, which isn't necessarily
compatible with C. The only robust solution is not to compile C code
with a C++ compiler (or ensure that your code is 100% valid as both C
and C++, which is harder than it seems; just getting 100% valid ANSI C
is difficult enough).

> #ifdef __c_plus_plus /* Check this macro defnition, it's a close variant of
> this */

It's actually "__cplusplus".

-- 
Glynn Clements <glynn.clements@virgin.net>

      reply	other threads:[~2003-01-03  3:49 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-12-26 15:22 integrating c code and c++ code qhwang
2002-12-26 17:24 ` Joseph D. Wagner
2002-12-26 21:15   ` supersets (Was: RE: integrating c code and c++ code) Glynn Clements
2002-12-26 20:50 ` integrating c code and c++ code Glynn Clements
2003-01-02 16:24   ` Jamie Risk
2003-01-03  3:49     ` Glynn Clements [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=15893.2133.819501.402598@cerise.nosuchdomain.co.uk \
    --to=glynn.clements@virgin.net \
    --cc=jamie_risk@yahoo.ca \
    --cc=linux-c-programming@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).