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...

How do you link a C++ program to C functions?

Answer Posted / ravindranath m

The C++ compiler does something called as "name mangling"
for functions, while a C compiler does not. Name mangling
is a process wherein the name of the original function in a
c++ program gets changed to a new name via adding some
prefix and/or postfix to it.

As a result, a c program cannot find the required definition
when trying to link to a cpp object file.

This can be resolved by putting the following declaration in
a c++ header file that contains the cpp function declarations.
#ifdef __cplusplus
extern "C" {
#endif

// function declarations go here...
// ...

#ifdef __cplusplus
}
#endif

Is This Answer Correct ?    25 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between an array and a list?

985


What is vector string in c++?

1042


What is setbase c++?

1062


Explain the differences between private, public and protected and give examples.

968


Define Virtual function in C++.

1045


Why is c++ is better than c?

916


What are the uses of typedef in a program?

1041


What are the differences between new and malloc?

1059


How many different levels of pointers are there?

1161


What is the use of endl in c++ give an example?

1118


What are friend functions in C++?

1017


Describe public access specifiers?

1051


What is command line arguments in C++? What are its uses? Where we have to use this?

1195


What do you mean by early binding?

1022


What's the most powerful programming language?

997