Linked by lucas_maximus on Tue 12th Apr 2011 23:37 UTC
General Development No April Foolery: The Portable C Compiler version 1.0 was released on April 1st! As with so many things BSD, this project proves that good code is timeless and can benefit from literally generations of review. It can build the majority of the BSD base systems (C++ code aside) and is undergoing continuous improvement.
Thread beginning with comment 470000
To read all comments associated with this story, please click here.
C++
by Earl Colby pottinger on Wed 13th Apr 2011 12:42 UTC
Earl Colby pottinger
Member since:
2005-07-06

C++ just needs a pre-processor program? Right?

Would they use one already written, or are they developing that too?

Reply Score: 2

RE: C++
by reduz on Wed 13th Apr 2011 16:11 in reply to "C++"
reduz Member since:
2006-02-25

that's something that always intrigued me..
there are many C++ compilers, but all just compile down to intermediate code, not C. Given the difficulty of making a C++ compiler, i'm surprised that there isn't a "generic" C++ -> C frontend that can be used with the plenty of C compilers available.

Reply Parent Score: 2

RE[2]: C++
by AnyoneEB on Thu 14th Apr 2011 01:00 in reply to "RE: C++"
AnyoneEB Member since:
2008-10-26

C++ was originally implemented via translation to C using a compiler called Cfront. See Wikipedia for more information: https://secure.wikimedia.org/wikipedia/en/wiki/Cfront . That article references a proprietary compiler project that I had not heard of before called Comeau C/C++ which apparently does still use the strategy of compiling C++ by going through C.

I think the problem is that it is useful for the compiler to know about C++'s features later on in the compiler pipeline. Converting them all to C probably makes the compiler harder to write and loses optimization opportunities.

Reply Parent Score: 1

RE: C++
by Stratoukos on Wed 13th Apr 2011 23:46 in reply to "C++"
Stratoukos Member since:
2009-02-11

"Just a preprocessor" doesn't really mean anything.

A preprocessor is, to quote wikipedia, "a program that processes its input data to produce output that is used as input to another program". You still have to do all the hard work of parsing the code and generating the appropriate IR. At this point you'll have written a compiler frontent, so you might as well stick LLVM at the backend and emit machine code (instead of generating C and then compiling that with PCC). C++ especially is notoriously difficult to parse, so it doesn't really make sense to write a C++ to C compiler.

Reply Parent Score: 2

RE: C++
by mikemikemike on Thu 14th Apr 2011 18:44 in reply to "C++"
mikemikemike Member since:
2008-11-14

PCC is somewhat tied to OpenBSD. OpenBSD is actually working on eliminating all C++ from their basic tree. For example, they just got rid of groff for that very reason and replaced it with their own man-page preprocessor.

Reply Parent Score: 1

RE[2]: C++
by blinkkin on Thu 14th Apr 2011 20:30 in reply to "RE: C++"
blinkkin Member since:
2011-04-14

Not exactly.

AFAIK Anders Magnusson (main developer of PCC) started revisiting old code of PCC after experience with porting NetBSD to PDP-10 (KLH10 emulator to be specific). Most problems with porting were related to GCC, not NetBSD itself.

Most work on mdocml (which replaced groff in OpenBSD) were done by Kristaps Dzonsons - NetBSD developer. NetBSD had even Google of Summer Code program related to mdocml.

Nerveless people from OpenBSD had great impact on both projects. Many BSD projects those days are maintained by more than one community.

Reply Parent Score: 1