PDA

Click to See Complete Forum and Search --> : Question about differences between c and c++


Sep 19th, 2000, 02:21 PM
Hey whats up all..

I have VC++ COMPILER on my puter and i grabbed a bunch of C source codes from a site...so what i am asking is..what huge drastic change of life will i have to go through to use these C codes on my VC++ compiler? ..i have been told there wasnt a huge difference between C and C++ but then again we are dealing with Microsoft Compiler here..so anything is possible.

Any help will be appreciated.

parksie
Sep 19th, 2000, 04:00 PM
Any C++ compiler will compile C. Just chuck your C source through. Although, if you want to use C functions from C++, you have to use the extern "C" trickery, which is a bit complex and documented on MSDN.

Sep 19th, 2000, 05:48 PM
When you say

"Although, if you want to use C functions from C++, you have to use the extern "C" trickery, which is a bit complex and documented on MSDN."

You are saying..if i want to use C functions in a C++ program i would have to do that "C" Trick? or if i wanted to use a C++ function in a C program i would have to do the "C" trick?


Thanks Parksie.














"I know am an *******..it says so on mah birth certificate!"

parksie
Sep 20th, 2000, 12:25 PM
Okay. Here's a scenario:

You are given a .obj file, compiled on a C compiler by someone. You also have the header file. However, if you just include it, the linker will complain about not finding names. This is because, to support inheritance and overloading, C++ compilers "mangle" function/variable names. Therefore, you would do this:

extern "C" {
#include "c_include.h"
}

which tells the C++ compiler to use the C naming rules when compiling.