Sujet : Re: Top 10 most common hard skills listed on resumes...
De : antispam (at) *nospam* fricas.org (Waldek Hebisch)
Groupes : comp.lang.cDate : 09. Sep 2024, 03:06:15
Autres entêtes
Organisation : To protect and to server
Message-ID : <vbll6l$2dpn7$2@paganini.bofh.team>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14
User-Agent : tin/2.6.2-20221225 ("Pittyvaich") (Linux/6.1.0-9-amd64 (x86_64))
Keith Thompson <Keith.S.Thompson+
u@gmail.com> wrote:
Waldek Hebisch <antispam@fricas.org> writes:
Bart <bc@freeuk.com> wrote:
[...]
I had a problem with this code because it was so verbose. The first
thing I did was to define aliases u64 and u32 for those long types:
typedef unsigned long long u64;
typedef unsigned long u32;
>
This code runs in 33 bit i386, 32 bit ARM and 64 bit x86-64, in
all cases under Linux. As Keith noticed, most popular of those
has 64-bit long. So your definition would break it. You need
>
typedef unsigned int u32;
Just add #include <stdint.h> and use uint32_t -- or, if you value
brevity for some reason:
typedef uint32_t u32;
(Bart dislikes <stdint.h>, but there's no reason you should.)
1. Well, I used to care about pre-Ansi compilers and for benefit
to them I got into habit of avoiding <stdint.h>. Yes, it is time
to change and on microcontrollers I use <stdint.h> as sizes
are important there and I do not expect to ever compile
microcontroller code with non-Ansi compiler.
2. As I explanined fixed size is just current state of developement.
On 64-bit machines code should use bigger types. And to get
128-bit type it seems that I need nonstandard type (there seem
to be new types in C23, but I did not investigate them deeper).
-- Waldek Hebisch