Re: data types
- From: "santosh" <santosh.k83@xxxxxxxxx>
- Date: 2 Mar 2007 17:32:46 -0800
koolj96825@xxxxxxxxx wrote:
Hi,
I've been working on this project for the past few months in my spare
time, and now I started working on the windows interface and going
over my petzold book, I've come to the realization that an int could
be 32-bit for PCs.
For a particular C implementation an int is (sizeof(int) * CHAR_BIT)
bits. For modern PCs it's often 32 or 64.
Oh, I could kick myself for not checking good in
the beginning, but the manual for the compiler I am using says int is
16-bit. It may be out of date.
Could be.
Anyway, now that I need to go back over and look closely at my code,
my question is: is there a way to declare a variable say a 16 bit
unsigned integer in C? Or is declaring it "short" the only specifier
that may work?
Why do you need an object of exactly N bits?
If your compiler is not a C99 one, as it appears to be, then you'll
have to define a 16-bit type yourself. It's not difficult. For
example, if, under your implementation, int happens be 16 bits then
unsigned int is the type you want. You can create an alias like:
typedef unsigned int int16;
But unless you have a specific requirement, I suggest installing a
current compiler system. You have many choices for Windows, though I
recommend either a version of gcc, (Cygwin or MinGW), or Visual Studio
Express.
If your implementation does support C99, (and you don't mind partial
support), have a look at the types in stdint.h. uint16_t or
uint_least16_t may meet your needs.
.
- Follow-Ups:
- Re: data types
- From: koolj96825
- Re: data types
- References:
- data types
- From: koolj96825
- data types
- Prev by Date: Re: data types
- Next by Date: Re: Please help me to catch this error
- Previous by thread: Re: data types
- Next by thread: Re: data types
- Index(es):
Relevant Pages
|
|