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

Can you write a function similar to printf()?

1082


Is java based off c++?

935


How do you clear a set in c++?

1020


How to demonstrate the use of a variable?

1051


Are c and c++ different?

937


What are multiple inheritances (virtual inheritance)?

1023


What does the ios::ate argument do?

1123


What are member functions used in c++?

1077


Why do we use the using declaration?

1120


Is c++ a software?

1147


What is the basic structure of c++ program?

1036


Can class objects be passed as function arguments?

1014


What is fflush c++?

953


What is function overriding in c++?

1022


How can a called function determine the number of arguments that have been passed to it?

1081