Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

What is name mangling?

Answer Posted / lovly

Name mangling is the encoding of function and variable
names into unique names so that linkers can separate common
names in the language. Type names may also be mangled. The
compiler generates function names with an encoding of the
types of the function arguments when the module is
compiled. Name mangling is commonly used to facilitate the
overloading feature and visibility within different scopes.
Name mangling also applies to variable names. If a variable
is in a namespace, the name of the namespace is mangled
into the variable name so that the same variable name can
exist in more than one namespace. The C++ compiler also
mangles C variable names to identify the namespace in which
the C variable resides.

The scheme for producing a mangled name differs with the
object model used to compile the source code: the mangled
name of an object of a class compiled using one object
model will be different from that of an object of the same
class compiled using a different object model. The object
model is controlled by compiler option or by pragma.

Name mangling is not desirable when linking C modules with
libraries or object files compiled with a C++ compiler. To
prevent the C++ compiler from mangling the name of a
function, you can apply the extern "C" linkage specifier to
the declaration or declarations, as shown in the following
example:

extern "C" {
int f1(int);
int f2(int);
int f3(int);
};

This declaration tells the compiler that references to the
functions f1, f2, and f3 should not be mangled.

The extern "C" linkage specifier can also be used to
prevent mangling of functions that are defined in C++ so
that they can be called from C. For example,

extern "C" {
void p(int){
/* not mangled */
}
};

Is This Answer Correct ?    3 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Out of fgets() and gets() which function is safe to use?

1115


How many ways can a variable be initialized into in C++?

1005


If you want to share several functions or variables in several files maitaining the consistency how would you share it?

969


In int main(int argc, char *argv[]) what is argv[0] a) The first argument passed into the program b) The program name c) You can't define main like that

1081


What are the benefits of oop in c++?

1209


Difference between pointer to constant vs. Pointer constant

1109


What is the default access level?

1054


Should a constructor be public or private?

1014


Write a Program for find and replace a character in a string.

1062


Write about the retrieval of n number of objects during the process of delete[]p?

1006


How to declaring variables in c++?

1148


What can I safely assume about the initial values of variables which are not explicitly initialized?

1040


How does a copy constructor differs from an overloaded assignment operator?

1024


Explain all the C++ concepts using examples.

1191


How do you clear a buffer in c++?

948