hi ppl ,,,
i am having a doubt is there a way that my c++ program could be executed in a c compiler,,,
thought of asking thats wy
if u know pls let me know k...
Printable View
hi ppl ,,,
i am having a doubt is there a way that my c++ program could be executed in a c compiler,,,
thought of asking thats wy
if u know pls let me know k...
program is executed by the OS...
it is compiled by the compiler.
What C-compiler you are talking about?
42
If that's not the answer you were looking for, you'll have to re-phrase the question.
Quote:
Originally Posted by vart
i mean there will be some c++ statements which is not present in c... is it possible to make those also execute ????
if you succeded in compiling the code, all statements will be executed.
But I don't understand why do you want a mix?
Make 2 file, one containing only C code, one - only C++, compile them with the corresponding compiler, then link together
hi thanks for replyng
i dont n=know how to link two files,.,,
i am new to this prog biz,,, can u help me out??
what are the two files i need to link togethere and what are those files (exe) or anything ?/
what compiler?
If you are using a fully compliant C compiler ie: all your file names end in .c, it will not understand C++ code. But you can compile C code using a C++ compiler as it has backward compatability with C.
To my knowledge there is no possible way to force a C compiler to fully execute C++ code.
Although Im sure Il be corrected on this by Vart! :)
Probably not, swgh. Although C and C++ are very similar, still asking a C compiler to compile C++-specific code is, in the end, like asking a Fortran compiler to compile Haskell: completely absurd.
yes and no...Quote:
Originally Posted by CornedBee
Due to OPs lack of exact terming, he can talk for example about VC++...
The IDE is using by default C-compiler for c-files and C++ compiler for cpp files... And there is a way to change the default behavior. So the c-file will be compiled by the c++ compiler
take this as a rule :
Any C++ compiler can compile both C++ and C codes
Any C compiler can only compile C code
No, don't. C++ is not a perfect superset of C, and thus not all C programs are valid C++ programs.
Just compile C code with a C compiler and C++ code with a C++ compiler. Any C++ compiler I've ever seen comes with a C compiler too. (They tend to share a lot of code, too.)
It's relatively safe to assume that a modern C++ compiler will be able to handle a .c sourcecode fine though. There are probably exceptions (MSVC6 comes to mind...) but for the most part, it's pretty much the way it is.
Are the C libraries (e.g stdio.h) that are available to C++ compilers up to the C99 standard, or are they just tools of the C++ified libraries (e.g cstdio) and thus possibly diverged from C? I think that that question is integral to this subject.
Probably depends on the compiler...I've never had any problems using Intel's or Borland's C++ compilers to compile C code, and obviously gcc doesn't have any problems. MSVC6 requires some occasional project tweaking to compile correctly though, but I don't specifically know about later MSVC builds (they're probably alright since Microsoft suddenly got anal about standards compliance).