[comp.sys.mac.programmer] Think C and MPW C byte ordering

bkahn@archive.rtp.dg.com (Bruce Kahn) (07/31/90)

  I am new to programming the 68K and have a quick question for you Mac C
gurus out there.  What is the byte ordering of the values generated by
both Think C 4.x and MPW C 3.x?  I own both but cant seem to find the
information in any of the manuals.
  Also, can someone pls tell me the sizes and values for variables
declared as Ctype * under Think C?  Under MPW its 4 bytes, 0 to
4294967295.  Thanks.
						Bruce (bkahn@archive.rtp.dg.com)

minow@mountn.dec.com (Martin Minow) (07/31/90)

In article <684@dg.dg.com> bkahn@archive.rtp.dg.com (Bruce Kahn) writes:
>
>  I am new to programming the 68K and have a quick question for you Mac C
>gurus out there.  What is the byte ordering of the values generated by
>both Think C 4.x and MPW C 3.x?  I own both but cant seem to find the
>information in any of the manuals.

They probably wanted you to ignore the byte ordering (doing so makes
your code portable to a "real" computer, such as a Vax).  If you must
know, try writing a program like

	union {
	    short	foo;
	    char	bar[sizeof (short)];
	} stuff;
	int		i;

	for (i = 0; i < sizeof (short); i++)
	    stuff.bar[i] = i;
	printf("%x\n", stuff.foo);

to see what the order is.
	
>  Also, can someone pls tell me the sizes and values for variables
>declared as Ctype * under Think C?  Under MPW its 4 bytes, 0 to
>4294967295.  Thanks.

Pointer types are 4 bytes in both implementations.  MPW int's are 4 bytes,
I am told, while int's in Think C are 2 bytes.  Either is "correct" given
the Motorola 68000 architecture.  Here, too, printf("%d\n", sizeof (Ctype *))
would give you the answer.

Martin Minow
minow@bolt.enet.dec.com