what dose it mean?

S

snnn

///////////////////////
#ifdef __cplusplus
extern "C" {
#endif
////////////////////////
I often find it at c/c++ head files.
 
E

Efrat Regev

1. This has to do "name mangling" explained below, and
2. It is used for "connecting" C and C++ code, so that your project can
include both.

Suppose you write a method named "foobar". When your compiler turns your
code into an executable, it doesn't have to retain the *name* foobar; it can
change it let's say into "shmilky", as long everyone else knows that
"shmilky" really means the method you called "foobar". As a *user* of the
compiler, you usually shouldn't have to care about this.

Why would your compiler do that in the first place? probably not much of
an issue if you're not writing a compiler (check name mangling in Google, if
you're interested).
Why the extern "C", then? C and C++ are different languages, and would
understand "shmilky" differently. The extern "C" causes both of them to
understand that "shmilky" stands for "foobar" (which is what you want).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top