[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: what does `extern "C++" ` mean?
From: |
Paul Pluzhnikov |
Subject: |
Re: what does `extern "C++" ` mean? |
Date: |
31 Jan 2005 22:48:15 -0800 |
User-agent: |
Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.4 (Artificial Intelligence) |
"Andy" <gnu04@yahoo.com> writes:
> Why we need such code?
Consider what happens if you put C++ code into a header, and someone
#includes your header this way:
extern "C" {
#include "foo.h"
}
If you provided a declaration for e.g. 'extern int foo();' in
foo.h, that function has suddenly aquired 'extern "C"' linkage,
and your end-user will be very confused when he links against
libfoo.so and gets unresolved 'foo' reference.
By explicitly stating C++ linkage, you protect your code from such
a possibility, and save time on support calls.
Cheers,
--
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.