Thread View: net.lang.c++
2 messages
2 total messages
Started by Bjarne Stroustrup
Sat, 15 Feb 1986 15:45
porting C++
Author: Bjarne Stroustrup
Date: Sat, 15 Feb 1986 15:45
Date: Sat, 15 Feb 1986 15:45
57 lines
3155 bytes
3155 bytes
> From: page@ulowell.UUCP (Bob Page)
> Newsgroups: net.lang.c++
> Subject: Non-SysV versions
> Date: Fri, 14-Feb-86 11:33:58 EST
> Organization: University of Lowell
> I've just ordered c++ from AT&T, for SV (of course). I don't run SysV;
Really, so why did you order the SysV version? Seriously, though, the standard
distribution tape has a BSD version on it. Just say ``make'' in the bsd directory
and it makes itself on a BSD. Did you notice that you can ask for either a cpio
tape or a tar tape? The only difference between SysV and BSD for the translator
is that the Berkeley people has a slightly different stdio.h. The translator
depends only on <stdio.h> and <ctype.h>. This typically makes porting trivial.
Actually, I work on an 8th Edition, so the C++ translator couldn't depend on
specific features particular to either SysV or BSD.
The translator comes with a full set of header files for SysV (but not with
a full set for BSD).
> I intend to port it to 4.[23]BSD, Ultrix-32 V1.[012] and DG/UX (a SysV
> lookalike with nearly full 4.2BSD libraries too).
Don't worry too much about porting C++. I it quite easy once you get used to it.
Just compile the translator C++ source into (intermediate) C for the target
machine. For that you use the -I option to supply standard headers for the target
system and +x to supply size and alignment information for the target system.
You then compile the resulting C on the target system and it ought to work.
Often it does not because of mistakes you make or because of bugs in the target
machine's C compiler. For example, the Apollo compiler can/could not handle
switch (i) {
int a; // <*** the problem
case 1:
...
};
so you have to move the declaration of "a" in the intermediate C code.
(this C compiler bug were reported to Apollo 3 years ago). Another example:
the Sun C compiler used not to accept constructs like ``(int) a/2''. The cast
was the problem. A nastier class of problem occurs when you get the size/align
file wrong. Maybe someone could post ``good'' size/align files for machines on
the net?
A reminder: You need a machine with near a megabyte of memory to have the
translator translate itself without modification. You need a C compiler that
handles structure assignment, and a linker that supports long names (you can
live with 31 characters, but more is better). You need a system that provides
a stdio.h.
> Thanks -
>
> ..Bob
> --
> UUCP: wanginst!ulowell!page Bob Page
> ARPA: page@ulowell.CSNET U of Lowell CS Dept
> VOX: +1 617 452 5000 x2233 Lowell MA 01854 USA
- Bjarne Stroustrup (AT&T Bell Labs, Murray Hill)
Re: porting C++
Author: Joseph Pallas
Date: Sun, 16 Feb 1986 23:15
Date: Sun, 16 Feb 1986 23:15
39 lines
1644 bytes
1644 bytes
With respect to size/align files, I wrote this little bit of code in C
that generates some (but not all) of the required information. Can anyone
tell me why the compiler wants some of the more obscure stuff, and how I
can figure it out at runtime in a C program?
/* alignments tester */
struct c { char c1; char c2;};
struct s { char c; short s;};
struct i { char c; int i;};
struct l { char c; long l;};
struct f { char c; float f;};
struct d { char c; double d;};
struct ch { char c;};
struct st { char c; struct ch sc;};
struct wp { char c; int *wp;};
struct bp { char c; char *bp;};
#define CHECK(name,type,struc) printf("%s %d %d\n",\
name, sizeof(type), sizeof(struc) - sizeof(type))
main()
{
CHECK("char", char, struct c);
CHECK("short", short, struct s);
CHECK("int", int, struct i);
CHECK("long", long, struct l);
CHECK("float", float, struct f);
CHECK("double", double, struct d);
CHECK("struct", struct ch, struct st);
CHECK("wptr", int *, struct wp);
CHECK("bptr", char *, struct bp);
}
---
Joe Pallas
...decwrl!glacier!navajo!pallas
pallas@navajo.stanford.edu
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads