On 12/02/2014 12:45 PM, Holm Tiffe wrote:
Jon Elson wrote:
No, thats not stupid. Nobody says that the compiler should think about your
code.
You clearly shift the int variable 32 times to the left and the compiler is
warning you..
BTW: there are some standards in stdint.h that clarify up a lot which tpe
has how many bits, eg int32_t int64_t uint8_t.
On my system int is 64 Bits and a long long is 128 bits, for shure your
code will work here, bit your code isn't portable! It doesn't work on a
32 Bit system and it doesn't work on 16 or 8 Bit machines.
C is much like Assembler, you should know what you really want todo. The
comiler let you do all kind of things with the assumption that you know what
you are doing. This is a programming language for system programming
purposes (written to write Unix) where you have to load unusual registers
and such things...
Not my code, it just took me longer to find this than it
should have. I do a lot of
device control stuff in C, so appreciate that bit fields are
easy to work with.
Yes, in my code, I have moved to using uint32_t and similar
types, and get RID
of the int, long int, long long int that don't have a
totally explicit meaning on
different systems. We just moved some data acq software to
some 64-bit
systems, and had to deal with a LOT of non-explicit data
types that would compile
differently on 32- and 64-bit systems.
Jon