C* problem with structures

KnightRider prk at planet.bt.co.uk
Mon Dec 24 19:42:53 AEST 1990


mcn at lanl.gov (Michael C. Neuman) writes:

>I have the following set of code which just refuses to compile under
>'ncs' for the Connection Machine:

>[...]
>typedef struct {double hlong,hlat,hrad;} polar;
>typedef struct {double x,y,z;} cart;

>cart polarconv(what)

	This line tells the compiler you want to return a whole struct
	from this function call.  Some compilers will allow this, others
	won't.

>polar what;

>{
>[...]


>  It gives me a syntax error on the line "cart polarconv(what)". Also,
>this same code compiles just fine using 'cc' on a Sun. WHY? :-)

	See above

>  Also, the compiler doesn't seem to like code like this:

>#define RADDEG 57.29

	If you use this constant, your result will be off by about
	100ppm, doesn't sound like a lot but it accumulates...
	(This is one of the less well known parts of Murphy's law:
		Randon errors add up in a single direction..

Try 

const double raddeg = 45.0/ atan (1.0);
	

>[...]
>double x;

>x=cos(180/RADDEG); /* math.h included */
>[...]

	180 is an integer constant, not a double one.  Try substituting
	  180.0

>  Can anyone tell me what I'm doing wrong? Thanks!


>-- 
>*******************************************************************************
>*  Mike Neuman  *  "Well, I dunno, but I guess the Cray will have to suffice."*
>*  mcn at lanl.gov *   - When one can't run a program on a Connection Machine    *
>*******************************************************************************


Peter Knight

BT Research 

#include <std.disclaimer>



More information about the Comp.lang.c mailing list