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

give me an example for testing a program showing the test path .show how the test is important and complex.

2921


Define the process of error-handling in case of constructor failure?

1011


Why the usage of pointers in C++ is not recommended ?

1435


What is c++ runtime?

1100


Write a corrected statement in c++ so that the statement will work properly. if (4 < x < 11) y=2*x;

2011


How c functions prevents rework and therefore saves the programers time as wel as length of the code ?

1086


Write some differences between an external iterator and an internal iterator?

1011


What does the following code do: int c=0; cout< a) Undefined *Updated* b) 01 c) 00

1067


Is c better than c++?

1059


How many types of comments are there in c++?

983


What does floor mean in c++?

1060


What parameter does the constructor to an ofstream object take?

1049


What are arithmetic operators?

989


What c++ is used for?

1067


What is different in C++, compare with unix?

1086