[comp.sys.apple2] Q: MPW IIGS C 1.0.1 type sizes

bkahn@archive.rtp.dg.com (Bruce Kahn) (08/09/90)

  Ok, I appreciate all the help that many of you gave me on my last type
query so Im asking another easy question.  I have MPW IIGS C 1.0.1 and want
to know the type sizes for all possible C types (table at bottom) under
MPW IIGS C.  They are not listed in the manual (that I can find) and 
Apple (DTS) wont answer my questions ("Why dont you post on the network?" 
where 'the network' is AppleLink; I will once my SE/30 is unpacked and my 
modem found).  I have some code Im trying to write for my Mac and Apple IIGS
but its somewhat picky about the sizings of some variables (assumptions
mostly).  Would some kind sould pls fill in the table below and either
email it to me or post it to the list?  Thanks.
 
						Bruce (bkahn@archive.rtp.dg.com)

Types:                         # of bytes                Range of values
un/signed char
	  char
un/signed int
	  int
un/signed short
	  short
un/signed long
	  long
	  float
     long float
	  double
     long double
	  enum
	  single
	  extended
          pointers (Ctype *)
          comp

dlyons@Apple.COM (David A. Lyons) (08/10/90)

In article <734@dg.dg.com> bkahn@archive.rtp.dg.com (Bruce Kahn) writes:

(How big are all of the MPW IIgs C data types?)

The compiler will tell you!  Run a program like this:

  printf("Size of char = %d\n", sizeof(char));
  printf("Size of unsigned char = %d\n", sizeof(unsigned char));
  ...
-- 
David A. Lyons, Apple Computer, Inc.      |   DAL Systems
Apple II Developer Technical Support      |   P.O. Box 875
America Online: Dave Lyons                |   Cupertino, CA 95015-0875
GEnie: D.LYONS2 or DAVE.LYONS         CompuServe: 72177,3233
Internet/BITNET:  dlyons@apple.com    UUCP:  ...!ames!apple!dlyons
   
My opinions are my own, not Apple's.

gwyn@smoke.BRL.MIL (Doug Gwyn) (08/11/90)

In article <734@dg.dg.com> bkahn@archive.rtp.dg.com (Bruce Kahn) writes:
>I have MPW IIGS C 1.0.1 and want to know the type sizes for all possible
>C types (table at bottom) under MPW IIGS C.

These are extremely easy to find out for yourself, empirically:
	#include <stdio.h>
	main() {
		printf( "%d\n", (int)sizeof(double) );
		return 0;
	}
for example.

bkahn@archive.rtp.dg.com (Bruce Kahn) (08/11/90)

In article <43828@apple.Apple.COM>, dlyons@Apple.COM (David A. Lyons) writes:
|> In article <734@dg.dg.com> bkahn@archive.rtp.dg.com (Bruce Kahn) writes:
|> 
|> (How big are all of the MPW IIgs C data types?)
|> 
|> The compiler will tell you!  Run a program like this:
|> 
|>   printf("Size of char = %d\n", sizeof(char));
|>   printf("Size of unsigned char = %d\n", sizeof(unsigned char));
|>   ...
|> -- 
|> David A. Lyons, Apple Computer, Inc.      |   DAL Systems
|> Apple II Developer Technical Support      |   P.O. Box 875
|> America Online: Dave Lyons                |   Cupertino, CA 95015-0875
|> GEnie: D.LYONS2 or DAVE.LYONS         CompuServe: 72177,3233
|> Internet/BITNET:  dlyons@apple.com    UUCP:  ...!ames!apple!dlyons
|>    
|> My opinions are my own, not Apple's.

  True (this Ive done for most of the types), what I was more interested in
and didnt ask about too clearly was the range of values that each type
can have and whether or not the default for that type is signed or
unsigned.  This can be done by simply looping but I dont want to wait for 
the program to dump or cycle around.  Anyone know the default ranges 
for the pointers, enum, single, comp, float, long float, double, and long
double as well as their default characteristic??

						Bruce (bkahn@archive.rtp.dg.com)

dlyons@Apple.COM (David A. Lyons) (08/12/90)

In article <756@dg.dg.com> bkahn@archive.rtp.dg.com (Bruce Kahn) writes:
>[...] True (this Ive done for most of the types), what I was more interested
>in and didnt ask about too clearly was the range of values that each type
>can have and whether or not the default for that type is signed or
>unsigned.

I believe the default is *always* signed.

Almost all the information you're asking for is on page 4-2 and 4-3 of
the MPW IIgs C manual.  I won't spend time typing it in without a good
reason.
-- 
David A. Lyons, Apple Computer, Inc.      |   DAL Systems
Apple II Developer Technical Support      |   P.O. Box 875
America Online: Dave Lyons                |   Cupertino, CA 95015-0875
GEnie: D.LYONS2 or DAVE.LYONS         CompuServe: 72177,3233
Internet/BITNET:  dlyons@apple.com    UUCP:  ...!ames!apple!dlyons
   
My opinions are my own, not Apple's.

gwyn@smoke.BRL.MIL (Doug Gwyn) (08/13/90)

In article <756@dg.dg.com> bkahn@archive.rtp.dg.com (Bruce Kahn) writes:
>... what I was more interested in and didnt ask about too clearly was
>the range of values that each type can have and whether or not the
>default for that type is signed or unsigned.

The signedness is defined by the C language, except for type "char"
where the implementation gets to choose.  What I don't understand is
why you would possibly care about this.  If you need an unsigned type,
use an unsigned type..

All the integers are twos-complement representations, so knowing the
number of bits (8 bits in a "char", others obvious from "sizeof"),
you should be able to easily compute the minimum and maximum representable
values for each integral type.  For floating-point formats, consult Apple's
Numerics Reference Manual (2nd Edition).

>Anyone know the default ranges for the pointers, ...

There is no such thing.