Subroutine layout in C
Wade Guthrie
evil at arcturus.UUCP
Tue Jan 10 02:49:27 AEST 1989
In article <18789 at agate.BERKELEY.EDU>, bowles at eris.berkeley.edu (Jeff A. Bowles) writes:
> I worked for a very short time for a creepy compiler company that had
> several hundred thousand lines of this sort of crap.
>
> PRIVATE -> static
> PUBLIC -> ""
> INT16 -> short int
> INT32 -> long int
In general I agree that typedefs and macros should be used judiciously
in order to help make things readable to the ordinary C programmer (if
you can call *any* C programmer ordinary :-> ). However, I have seen
the use for INT16 and INT32 -- portability where the precision is
absolutely important.
For example: you want to partition a circle into little angles, and you
want to flag an occurrence of something if it exists in each angle. The
way I chose to implement this was to partition my circle into 32 sections
(the number of bytes in the long or int on my machine -- to take advantage
of the speed improvements on some operations, I chose to use int) and do
bitwise operations to set and check flags represented by the bits in
that int. Now, I need to port this to a machine that has 16 bit ints --
portability falls on its face. This can be circumvented by using INT32
where the size is important (and using short, int, and long where it is
not so critical).
Wade Guthrie
evil at arcturus.UUCP
Rockwell International
Anaheim, CA
(Rockwell doesn't necessarily believe / stand by what I'm saying; how could
they when *I* don't even know what I'm talking about???)
More information about the Comp.lang.c
mailing list