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

How does a C++ structure differ from a C++ class?

1174


Differentiate between an inspector and a mutator ?

1287


Explain the term memory alignment?

1300


Why can templates only be implemented in the header file?

1142


program explaining feautures of c++

2490


Write a program for Divide a number with 2 and Print the output ( NOTE: Check for divide by zero error).

1155


Which software is best for coding?

1097


Name four predefined macros.

1100


Which is the best c++ compiler?

1127


Can you please explain the difference between using macro and inline functions?

1088


Which programming language should I learn first?

1150


Differences between private, protected and public and give examples.

1119


Write a single instruction that will store an EVEN random integer between 54 and 212 inclusive in the variable myran. (NOTE only generate EVEN random numbers)

2001


Tell me what are static member functions?

1132


What are the four main data types?

1133