Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!lll-winken!uunet!mcvax!kth!draken!Urd!newsuser From: newsuser@LTH.Se (LTH network news server) Newsgroups: comp.lang.c++ Subject: Re: C++ --> C Summary: Translated C++ is not so portable Message-ID: <1989Apr14.082659.19048@LTH.Se> Date: 14 Apr 89 07:26:59 GMT References: <173@cs.columbia.edu> Reply-To: dag@Control.LTH.Se (Dag Bruck) Organization: Dept. of Automatic Control, Lund Inst. of Technology, Sweden Lines: 41 In article <173@cs.columbia.edu> jordan@cs.columbia.edu (Jordan Hayes) writes: >Say you don't have a C++ compiler for a certain kind of machine, >but you do have a C compiler. > >Say you've got a Sun somewhere on the same network. > >Can you get g++ or cfront to generate C on the Sun and have the >unnamed machine compile that? I think you would be heading for a lot of work: 1. There are some machine dependent parts in your compiler, e.g., sizes of basic data types, alignment, etc. 2. The C code will have all macros and inline functions expanded. As many machine dependent issues are described by macros in the system header files, you must make sure the C++ compiler on the development machine uses the header files of the target machine. 3. Debugging the C code produced by the C++ compiler is not funny. Can you be sure you got it right? I am more willing to trust a ported compiler than a ported application. 4. Every change in the original C++ program (or even worse, a new release of system software on your target machine), requires you to port the application again. (It will of course be easier the n:th time.) My view is that the C code produced by a C++ compiler is not particularly portable, but I'm sure it can be, and has been, done. Assuming the target machine is "similar" to your Sun, I would try porting the compiler. I think that is more cost-effective in the long run. Dag Bruck -- Department of Automatic Control Internet: dag@control.lth.se Lund Institute of Technology P. O. Box 118 Phone: +46 46-108779 S-221 00 Lund, SWEDEN Fax: +46 46-138118