K
Kelsey Bjarnason
Now you're portable across implementations that support those types.
What types? The new int types which aren't required to even exist? Yes,
indeed. Portability goes straight down the crapper.
Now you're portable across implementations that support those types.
If your application requires fixed width types, your application
requires fixed with types. Why should giving them a standardised name
make you code less portable? The fixed width requirement has already
restricted its portability.
Kelsey said:[snips]
Do you REALLY find so hard to understand that some code does not have to
be portable to every system?
Do you REALLY find it so hard to understand that if you're writing code
where you _know_ the sizes involved on the implementation, you don't
_need_ the uint16_t crap in the first place, as people have been writing
this sort of code for 30 years and more without the new types?
Kelsey Bjarnason said:[snips]
Ok, show me how to write a typedef for a signed type that's exactly 32
bits wide, with no padding bits and a 2's-complement representation,
so that I don't have to change the definition for different platforms.
Oh, wait, somebody's already done that for you; it's called uint32_t.
Good. Show me where this is defined on a machine with 64-bit types.
Whoops. Doesn't exist. Next.
Show me where anybody claimed that it's defined on a machine with
64-bit types.
Kelsey said:[snips]
Then please show us your typedef for a type of *exactly* 32 bits on a
system with 9-bit char, 18-bit short, 36-bit int and long and 72-bit
long long.
And your uint32_t exists on a machine with 64-bit types, right?
Nope. Next.
In comp.std.c pete said:It looks like a draft of what will someday be
the corrected version of C99.
If that's what it is,
then I think that everybody who bought a C99 standard,
is entitled to the corrected version.
Harald van D?k said:Kelsey said:[snips]
On Thu, 06 Sep 2007 11:51:57 -0700, Keith Thompson wrote:
If you just want integer types of specified sizes, take a look at the
<stdint.h> header, which defines int8_t, int16_t, etc.
My copy of the draft says that intN_t types are optional, an
implementation is not required to provide them. As such, it strikes me
that code cannot rely on them unless one gives up portability across
compilers, never mind OSen.
Has this changed, or is this still little more than a good way to
guarantee you're stuck using one vendor's compiler for the rest of
eternity?
int8_t, int16_t, int32_t, int64_t and the corresponding unsigned integer
types are required on systems where there exist types matching the
descriptions. This means that on C99 implementations where they're not
defined, it wouldn't be possible to use some other type as a substitute
anyway, unless you didn't really need an exact-width integer type in the
first place.
It would have been good to mandate their support on _all_ architectures.
Odd bit sized and non 2's complement machines could emulate them in
software...
Such biests are disappearing fast at this time,
Keith Thompson said:Charlie Gordon said:"Harald van D?k" <[email protected]> a écrit dans le message de [email protected]... [...]
int8_t, int16_t, int32_t, int64_t and the corresponding unsigned integer
types are required on systems where there exist types matching the
descriptions. This means that on C99 implementations where they're not
defined, it wouldn't be possible to use some other type as a substitute
anyway, unless you didn't really need an exact-width integer type in the
first place.
It would have been good to mandate their support on _all_ architectures.
Odd bit sized and non 2's complement machines could emulate them in
software...
Such biests are disappearing fast at this time, and lack of complete c99
support for them would not have hurt anybody.
Definitely something to remember for the next release.
How would you emulate uint8_t (which, remember, must have no padding
bits) on an implementation with CHAR_BIT==9, which therefore cannot
support 8-bit objects?
You do not emulate its representation, but you can emulate its well defined
arithmetic behaviour with available hardware operations and appropriate
masks, shifts, etc. The compiler is already doing something very similar
for bitfields.
What types? The new int types which aren't required to even exist? Yes,
indeed. Portability goes straight down the crapper.
Kelsey Bjarnason said:[snips]
On Wed, 12 Sep 2007 11:34:45 -0700, Keith Thompson wrote:
Ok, show me how to write a typedef for a signed type that's exactly 32
bits wide, with no padding bits and a 2's-complement representation,
so that I don't have to change the definition for different platforms.
Oh, wait, somebody's already done that for you; it's called uint32_t.
Good. Show me where this is defined on a machine with 64-bit types.
Whoops. Doesn't exist. Next.
Show me where anybody claimed that it's defined on a machine with
64-bit types.
So we're agreed: if you rely on the new int types, you can toss portability
right out the freakin' window, and on the flip side, the "benefit" to
these types is... to avoid writing a typedef.
You keep saying that. The new types *are* required to exist
, if the
implementation can support them.
This might be a good place to note that N1256, an updated draft
incorporating the new TC3, has just been published:
<http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf>
If writing a typedef will do the job, then so will the new int type.
The difference is that the new int type will work on *all*
implementations which have *any* suitable type
Charlie Gordon said:Keith Thompson said:Charlie Gordon said:"Harald van D?k" <[email protected]> a écrit dans le message de [email protected]... [...]
int8_t, int16_t, int32_t, int64_t and the corresponding unsigned integer
types are required on systems where there exist types matching the
descriptions. This means that on C99 implementations where they're not
defined, it wouldn't be possible to use some other type as a substitute
anyway, unless you didn't really need an exact-width integer type in the
first place.
It would have been good to mandate their support on _all_ architectures.
Odd bit sized and non 2's complement machines could emulate them in
software...
Such biests are disappearing fast at this time, and lack of complete c99
support for them would not have hurt anybody.
Definitely something to remember for the next release.
How would you emulate uint8_t (which, remember, must have no padding
bits) on an implementation with CHAR_BIT==9, which therefore cannot
support 8-bit objects?
You do not emulate its representation, but you can emulate its well defined
arithmetic behaviour with available hardware operations and appropriate
masks, shifts, etc. The compiler is already doing something very similar
for bitfields.
I don't normally make one-line replies but: Hear hear.
Chris Hills said:The paragraph in the draft you are looking at may be identical to the
one in the ratified standard BUT other paragraphs in the standard, but
not in the draft, may alter the use of the one paragraph you have
quoted.
In high integrity, safety critical or other controlled development
environments (IS) 9K, CMM etc using an uncontrolled document ie a
draft can get you sacked. And rightly so.
A Draft is just that. I know personally from working on these
standards that many things can change between draft (eve final draft)
and publication. If you use a Draft when there is a published standard
then you don't have a leg to stand on.
Just because the one paragraph is the same it don't mean a
thing. Especially when the other paragraph in the publish standard,
but not in the draft, does have a bearing on the paragraph you are
quoting... but you knew that didn't you?
Kelsey said:[snips]
You keep saying that. The new types *are* required to exist
Really? So uint8_t exists on a machine with 64-bit char and short and int
and long? No, it doesn't. Continuing...
, if the
implementation can support them.
"If". And if it doesn't, they don't exist.
Exactly my point. So we're all agreed. Good.
So I now have new int types which, as I keep - correctly - stating aren't
required to exist, so that using them means portability goes straight down
the crapper.
We *are* all in agreement on this, right?
[snips]
Do you REALLY find so hard to understand that some code does not have to
be portable to every system?
Do you REALLY find it so hard to understand that if you're writing code
where you _know_ the sizes involved on the implementation, you don't
_need_ the uint16_t crap in the first place, as people have been writing
this sort of code for 30 years and more without the new types?
Do you REALLY find it so hard to understand that these types offer no real
benefit in this case, and _cannot_ be relied on in pretty much any other
case, rendering them completely worthless?
Show me where anybody claimed that it's defined on a machine withKelsey Bjarnason said:[snips]
On Wed, 12 Sep 2007 11:34:45 -0700, Keith Thompson wrote:
Ok, show me how to write a typedef for a signed type that's exactly 32
bits wide, with no padding bits and a 2's-complement representation,
so that I don't have to change the definition for different platforms.
Oh, wait, somebody's already done that for you; it's called uint32_t.
Good. Show me where this is defined on a machine with 64-bit types.
Whoops. Doesn't exist. Next.
64-bit types.
So we're agreed: if you rely on the new int types, you can toss portability
right out the freakin' window,
and on the flip side, the "benefit" to
these types is... to avoid writing a typedef.
A language feature of such limited apparent value that it causes this
much discussion is probably a dubious item at best, and when the only
benefit that's been offered thus far is to not have to create your own
typedef, the benefits just do not seem sufficient for this feature to
exist at all.
Meanwhile the downsides are pretty obvious: use the feature, forget
portability,
avoid the feature and we just end up with another "auto"
or
"gets"
- unwanted dross laying about cluttering things up.
Kelsey Bjarnason said:Kelsey Bjarnason said:[snips]
On Wed, 12 Sep 2007 11:34:45 -0700, Keith Thompson wrote:
Ok, show me how to write a typedef for a signed type that's exactly 32
bits wide, with no padding bits and a 2's-complement representation,
so that I don't have to change the definition for different platforms.
Oh, wait, somebody's already done that for you; it's called uint32_t.
Good. Show me where this is defined on a machine with 64-bit types.
Whoops. Doesn't exist. Next.
Show me where anybody claimed that it's defined on a machine with
64-bit types.
So we're agreed: if you rely on the new int types, you can toss portability
right out the freakin' window, and on the flip side, the "benefit" to
these types is... to avoid writing a typedef.
A language feature of such limited apparent value that it causes this
much discussion is probably a dubious item at best, and when the only
benefit that's been offered thus far is to not have to create your own
typedef, the benefits just do not seem sufficient for this feature to
exist at all.
Meanwhile the downsides are pretty obvious: use the feature, forget
portability, avoid the feature and we just end up with another "auto" or
"gets" - unwanted dross laying about cluttering things up.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.