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...
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?
All problems in computer science can be solved by another level of indirection,
except for the problem of too many layers of indirection.
– David J. Wheeler
42
If that's not the answer you were looking for, you'll have to re-phrase the question.
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
All problems in computer science can be solved by another level of indirection,
except for the problem of too many layers of indirection.
– David J. Wheeler
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?
All problems in computer science can be solved by another level of indirection,
except for the problem of too many layers of indirection.
– David J. Wheeler
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!
Double Helix STL
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.
All the buzzt!
CornedBee
"There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
- Flon's Law
yes and no...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
All problems in computer science can be solved by another level of indirection,
except for the problem of too many layers of indirection.
– David J. Wheeler
take this as a rule :
Any C++ compiler can compile both C++ and C codes
Any C compiler can only compile C code
"C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg."-Bjarne Stroustrup
Nearing the end of finishing my 2D card game! I have to work on its 'manifesto' though <_<
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.)
All the buzzt!
CornedBee
"There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
- Flon's Law
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.
Last edited by Nodtveidt; 01-12-2007 at 07:55 PM.
Code:cout << "Language comparisons are dumb"; echo("Language comparisons are dumb"); PRINT "Language comparisons are dumb" alert ("Language comparisons are dumb")
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.
"If you tell the truth, you don't have to remember anything"
-Mark Twain
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).
Code:cout << "Language comparisons are dumb"; echo("Language comparisons are dumb"); PRINT "Language comparisons are dumb" alert ("Language comparisons are dumb")