Re: Getting rid of int
From: gswork (gswork_at_mailcity.com)
Date: 08/26/04
- Next message: Jonathan Allen: "Testing Methods RFC"
- Previous message: kyle york: "Re: Are / Were you a Siebel Software Engineer?"
- In reply to: Jamie Vicary: "Getting rid of int"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 26 Aug 2004 07:07:47 -0700
Jamie Vicary <Xjamie.Xvicary@Xmansf.Xox.Xac.Xuk> wrote in message news:<cgi733$fmi$1@uns-a.ucl.ac.uk>...
> Dear all,
>
> I am writing a C library to deal with integer data for a specialised
> task. I am only giving support for unsigned short, signed short,
> unsigned long and signed long integers.
>
> I am neglecting signed and unsigned ints because, as far as I can tell,
> shorts are 4 bit, longs are 8 bit, and ints are either 4 or 8 bits
> depending on your compiler - seems like an unnecessary confusion to me.
> The user should know whether 4 or 8 bits is right for her program, and
> choose the right type accordingly.
The user of a lib should choose the types that are prescribed in the
lib's manual.
The fact is that int is a useful general purpose portable storage that
you can find in almost every c app, legacy and current.
For this reason a lib author would need to take that into account when
designing the lib and its interface
> Given this ambiguity, why is the int type so extensively used? Is there
> another advantage to having ints in addition to shorts and longs which I
> haven't realised?
To disambiguate you can use #defined 'types'
#define ANINT int
for a (bad!) example
Anyone who programs c using OS specific libraries and further uses a
number of third party libraries is well used to writing words in
CAPITALS whose definitions are #defined in one of many header files!
(to say nothing of all the constants!)
- Next message: Jonathan Allen: "Testing Methods RFC"
- Previous message: kyle york: "Re: Are / Were you a Siebel Software Engineer?"
- In reply to: Jamie Vicary: "Getting rid of int"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|