Saturday, May 22, 2010

Does a program written in C could possibly work with a C++ compiler?

Please don't write long epics! I just need an answer that i can read without scrolling down the mouse wheel

Does a program written in C could possibly work with a C++ compiler?
yes it should.
Reply:Almost always, as long as no mixing of fancy code from borland (bad), gnu gcc (ANSII %26amp; STL good), and Microsoft (bad).





If its good code it should port perfectly fine to CPP (C Pre Parser)
Reply:Yes it will. C is a sub set of C++. or C++ is a derived class of C.





Whatever it may be it will compile.
Reply:yes.....but, it should not conatin any features that are not in C++.
Reply:Yes, ofcourse
Reply:Possibly, yes. It depends on the code and the external functions that are called. Also, if the C source calls some procedures within the source file and there are no function prototypes declared, then the C++ compiler might complain about it.
Reply:yes it will work. No worries there.
Reply:Yes! Surely the need is just to #include all the files in which the prototypes of function used are kept.
Reply:Depends on the simplicity of the code.


C++ is a branch off C, so it really depends on the compiler. Most C++ compilers will not compile straight C code.
Reply:yes
Reply:no there is a possibility of not compiling a c in c++
Reply:Every valid "C" code is valid code for "C++".








Thank you.


Mandar Gurav.
Reply:first... hello!!!!


actually im not a professional C programmer but i think i now some stuff cause i love C language esp TURBO C....





so back to your question...





it should work ... but be sure that u do follow the C++ rules.


beacause turbo C do excepmtion on these rules..


example..


in decalring HEader FIles.. TUrbo C do allow codes without delclaring their Header file..


EX. the CLRSCR() it is under CONIO.h


many more.


FUNCTION prototype should be included in C++ but its allowed in turbo C...


i think thats it... ill send you more when i think one..








i hope it helps...
Reply:In most cases, you should have no difficulty compiling C source with a C++ compiler. Make sure the libraries referenced in the source are able to be found by the linker.


Different compilers may have different capabilities. Check your documentation. The "free" compiler GCC will do it.


No comments:

Post a Comment