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 can you link a c++ program to c functions?

1107


What are the 2 main types of data structures?

1125


What is the header file for setw?

1135


Write a function that swaps the values of two integers, using int* as the argument type?

1031


What are pointers, when declared, intialized to a) NULL b) Newly allocated memory c) Nothing. Its random

1139


what is a reference variable in C++?

1243


Can you use the function fprintf() to display the output on the screen?

1247


Where are setjmp and longjmp used in c++?

1125


What is a vector c++?

1179


What is a Default constructor?

1602


Write a C/C++ program that connects to a MySQL server and checks if the InnoDB plug-in is installed on it. If so, your program should print the maximum number of concurrent threads that the InnoDB plug-in can create

2636


Am pass the 10000 records to target in target I will take commit interval 15000 when I was stop the work flow what will happened

1563


How new/delete differs from malloc()/free?

1146


What are all predefined data types in c++?

1131


What are c++ variables?

1066