[comp.unix.ultrix] Porting code gives "unknown size" C compiler error

dpl@unix.cis.pitt.edu (David P. Lithgow) (11/20/90)

	To any who've ported C code from Ultrix/VAX to Ultrix/MIPS,
I'm getting a compiler error, and a friend of mine says that
it is a known error, but I can't find the soultion anywhere in the
Ultrix V3.0, V3.1C, V3.1D, or V4.0 documentation, or the
"Release Notes for RISC Processors".

	Here's the error:

# make prog
cc -O -c prog.c
ccom: Error: prog.c line 583: unknown size
	struct exec execb;
      -------------------^
...
...
... more errors due to above error
...
*** error code 1

Stop.
#
	This make works without problem under Vax/Ultrix V3.0, but
fails with the above error under MIPS/Ultrix V3.1D.

	I've rtfm-ed to no avail - can anyone help?  Is this a
known problem with a known workaround?

--
David P. Lithgow    Sr. Systems Analy./Pgmr. (unix,VMS), Univ. of Pittsburgh
Internet: dpl@vms.cis.pitt.edu, dpl@unix.cis.pitt.edu
USENET:  {allegra,bellcore,ihpn4!cadre,decvax!idis,psuvax1}!pitt!cisunx!dpl
CCnet(DECnet): CISVM{S123}::DPL       BITnet:  DPL@PITTVMS

mogul@wrl.dec.com (Jeffrey Mogul) (11/20/90)

In article <62195@unix.cis.pitt.edu> dpl@unix.cis.pitt.edu (David P. Lithgow) writes:
>I'm getting a compiler error, and a friend of mine says that
>it is a known error, but I can't find the soultion anywhere in the
>Ultrix V3.0, V3.1C, V3.1D, or V4.0 documentation, or the
>"Release Notes for RISC Processors".
># make prog
>cc -O -c prog.c
>ccom: Error: prog.c line 583: unknown size
>	struct exec execb;
>      -------------------^

This is not a compiler error, it's an unportable part of your program.
Vax systems use the old "a.out" object file format, but MIPS systems
use a format "similar to standard AT&T System V COFF".  (See "man a.out"
on your MIPS system for more info on that; "man a.out" on your Vax system
for comparison.)

On Vax systems (at least, Vax/Ultrix), "struct exec" comes from <sys/exec.h>
by way of <a.out.h>.  Look at /usr/include/exec.h, and you'll see some
#ifdef vax controls.  I believe that on MIPS/Ultrix, <a.out.h> doesn't
end up including <sys/exec.h> at all (more #ifdefs), but exec.h file
still defines the right structures.

Anyway, the "struct exec" declaration doesn't exist in the COFF (MIPS)
world, so when you compile your program on a MIPS system, the compiler
sees a declaration depending "struct exec" and doesn't know how much
space to allocate.  (If you had declared it "struct exec *" then
the compiler would have thought "aha! a pointer, I know how big those
are", but later on you might still have had grief.)  Not the best error
message in the world, but think "undeclared type" when the compiler
says "unknown size" and you should usually be right.

It looks like you're going to have to read the MIPS a.out manual page
and then #ifdef your sources.

-Jeff