Is there a standard way to write an 8 bit byte?
- From: Kristian Nybo <kristian@xxxxxxxxxxxxxxxxxx>
- Date: Mon, 02 May 2005 23:15:16 +0300
Hi,
I'm writing a simple image file exporter as part of a school project, and I would like to write completely platform-independent code if at all possible. The problem I've run into is that apparently there's no guarantee that a particular implementation will have a data type that is exactly 8 bits wide; char is only guaranteed to be at least 8 bits. Correct me if I'm wrong, but I assume that if CHAR_BIT happens to be, say, 9, writing a char into a file in binary mode would result in 9 bits being written.
At first it seemed that stdint.h and its uint8_t were the answer, but then I noticed that uint8_t is only guaranteed to exist if the platform has a data type that is exactly 8 bits wide, which put me back in square one.
Is there a way around this, or will I just have to use uint8_t and accept that my code might not work on every conceivable platform that has an ANSI C compiler?
Kristian .
- Follow-Ups:
- Re: Is there a standard way to write an 8 bit byte?
- From: Emmanuel Delahaye
- Re: Is there a standard way to write an 8 bit byte?
- From: Flash Gordon
- Re: Is there a standard way to write an 8 bit byte?
- From: Malcolm
- Re: Is there a standard way to write an 8 bit byte?
- From: Walter Roberson
- Re: Is there a standard way to write an 8 bit byte?
- Prev by Date: Re: dynamic char - realloc use
- Next by Date: Re: function pointers as function parameters
- Previous by thread: dynamic char - realloc use
- Next by thread: Re: Is there a standard way to write an 8 bit byte?
- Index(es):
Relevant Pages
|