[comp.lsi] compiling Magic on a SUN3 --- problem with Rect structures

clark@endor.UUCP (02/13/87)

	I have been trying to get Magic to run on a Sun110 workstation,
as are many others from what I can see from the net traffic on this
newsgroup. I have the 1986 release of the Berkeley design tools and
obtained source code as well as binaries for Magic on the distribution
tape. The binary works fine on the Sun3/160 and I am very happy with it.
However, running this binary form of Magic on a Sun3/110 is not so good,
as the software thinks the Sun3/110 is a black and white display device.
The Sun release manual for its version 3.2 operating system (which is
required for the Sun3/110s to work properly) says that programs which use
the display devices must be recompiled under the new operating system.
	O.K., I thought, all I have to do is recompile Magic. However,
when I attempted recompilation with the sources provided on the
distribution tape, I encountered a compiler error when compiling
routines in the ~cad/src/magic/graphics library. The errors occured in
those files containing statements for including  both 
the Magic include file geometry.h and the Sun include file
sunwindow/window_hs.h (such as grSun1.c etc.). The error occurs because
both of these include files (eventually) define a structure called
'Rect'. When the compiler gets to the definition in the geometry.h
file it craps out because the 'Rect' structure has already been defined.
The Magic definition is actually different than the Sun definition of
a Rect so one can not merely delete the Magic definition. I attempted to
fix the problem by modifying the Sun Include files (by creating a new
set of include files where the Rect was renamed to Rect2 and including
these new files only when geometry.h was also included. My idea was that
if a routine included geometry.h then the Rect structure it wanted was the
Magic one and not the Sun one. After doing this all of the Magic routines
compiled with no problem and the system installed O.K. However, the
program core dumps right at the beginning, even before the magic window
comes up. I feel that my trick with the altered include files is the
cause of the crashes.
	I am wondering if any body else has come across this problem,
and what they did about it. Obviously Magic must be compilable somehow
since I have a working (3.0 operating system version) binary. I find it
hard to believe that the developers of Magic would include structures
(Rect) that are already in use by the Sun graphics interface and not
make them equivalent. (By the way sunwindow/window_hs.h is a file
including other include statements; the actual definition of Rect is
found in sunwindow/rect.h).


Jim Clark
clark@harvard.harvard.edu
Division of Applied Sciences
Harvard University