Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| Message-ID | <4F747DFC.3090800@loria.fr> (permalink) |
|---|---|
| Date | 2012-03-29 17:21 +0200 |
| From | Jens Gustedt <jens.gustedt@loria.fr> |
| Newsgroups | comp.lang.c |
| Subject | Re: what would be the most portable way to test if UINT_MAX>=0xFFFFFFF with the preprocessor? |
| References | <4f7375a7$0$719$426a74cc@news.free.fr> <kfnaa30iej3.fsf@x-alumni2.alumni.caltech.edu> <4f73f7dc$0$1714$426a74cc@news.free.fr> |
| Organization | Guest of ProXad - France |
Am 03/29/2012 07:49 AM, schrieb Francois Grieu:
> I think that the preprocessor part of cross-compilers is allowed
> to use wider types than their target. 1U can be 64-bit as far
> as the preprocessor is concerned, even if UINT_MAX is 0xFFFF,
> right?
>
> At least, I met preprocessors which perform all their arithmetic
> over 32 bits, even though the compiler does not. In these
> #if ( 256<<8 ) is taken
> if ( 256<<8 ) is not taken
> and this is NOT a non-conformance AFAIK.
Since C99 the preprocessor arithmetic must be the one of {u}intmaxt_t
for the target platform. So your example is well possible.
The #-comparison is done in intmax_t and goes ok.
The other one is done with int. If int has only 16 bit 256<<8 is an
overflow and thus the behavior is undefined.
Jens
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
what would be the most portable way to test if UINT_MAX>=0xFFFFFFF with the preprocessor? Francois Grieu <fgrieu@gmail.com> - 2012-03-28 22:34 +0200
Re: what would be the most portable way to test if UINT_MAX>=0xFFFFFFF with the preprocessor? Tim Rentsch <txr@alumni.caltech.edu> - 2012-03-28 14:47 -0700
Re: what would be the most portable way to test if UINT_MAX>=0xFFFFFFF with the preprocessor? Francois Grieu <fgrieu@gmail.com> - 2012-03-29 07:49 +0200
Re: what would be the most portable way to test if UINT_MAX>=0xFFFFFFF with the preprocessor? Tim Rentsch <txr@alumni.caltech.edu> - 2012-03-28 23:51 -0700
Re: what would be the most portable way to test if UINT_MAX>=0xFFFFFFF with the preprocessor? Jens Gustedt <jens.gustedt@loria.fr> - 2012-03-29 17:21 +0200
Re: what would be the most portable way to test if UINT_MAX>=0xFFFFFFF with the preprocessor? ImpalerCore <jadill33@gmail.com> - 2012-03-28 14:14 -0700
Re: what would be the most portable way to test if UINT_MAX>=0xFFFFFFF with the preprocessor? China Blue Water Navy <chine.bleu@yahoo.com> - 2012-04-02 15:04 -0700
Re: what would be the most portable way to test if UINT_MAX>=0xFFFFFFF with the preprocessor? Francois Grieu <fgrieu@gmail.com> - 2012-04-03 18:15 +0200
csiph-web