Could I compile "c" source with a C++ compiler (Forte C++ Update 2)?

Could I compile "c" source with a C++ compiler (Forte C++ Update 2)?

Post by Jacob, Pa » Fri, 25 Mar 2005 16:23:24



Does Forte C++ Update 2 compiles C source code in ANSI C as same as
Forte C udpate 2 does?
 
 
 

Could I compile "c" source with a C++ compiler (Forte C++ Update 2)?

Post by Seongbae Par » Sat, 26 Mar 2005 02:08:38



> Does Forte C++ Update 2 compiles C source code in ANSI C as same as
> Forte C udpate 2 does?

If you're asking whether "CC" will compile the same code as "cc",
then the answer is no.
This is true for ANY standard-compliant c++ compiler
(compilers with different "language mode" like gcc
don't count as a single compiler for this description).
However, usually one can make C code
"compilable" by C++ compiler with modest effort.

If you want more detail and background on C vs C++,
you may want to read two papers written by Bjarne Stroustrup:

Sibling Rivaly: C and C++
http://www.research.att.com/~bs/sibling_rivalry.pdf

C and C++: a Case for Compatibility
http://www.research.att.com/~bs/compat_short.pdf

As for Sun compiler specific info,
C++ user's guide for Forte 6 update 2:

http://docs.sun.com/app/docs/doc/806-7991
--
#pragma ident "Seongbae Park, compiler, http://blogs.sun.com/seongbae/"