Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #89411
| From | Keith Thompson <Keith.S.Thompson+u@gmail.com> |
|---|---|
| Newsgroups | comp.lang.c++ |
| Subject | Re: strange error (QT Creator 4.12.2, based on QT creator 5.14.2) |
| Date | 2023-03-03 09:29 -0800 |
| Organization | None to speak of |
| Message-ID | <87edq5n3p1.fsf@nosuchdomain.example.com> (permalink) |
| References | <ttqilb$b9c8$1@dont-email.me> <ttqn9h$bpn9$1@dont-email.me> <ttr8f7$df6l$3@dont-email.me> <87ilfimysr.fsf@nosuchdomain.example.com> <ttsopt$kklh$1@dont-email.me> |
MarioCPPP <NoliMihiFrangereMentulam@libero.it> writes:
> On 03/03/23 02:03, Keith Thompson wrote:
>> MarioCPPP <NoliMihiFrangereMentulam@libero.it> writes:
[...]
>>> I knew that "short" are aligned at addresses multiple of 2, "int" are
>>> aligned at addresses multiple of 4, "long" are aligned at addresses
>>> multiple of 8 bytes.
>> If you mean that you know that's the case for the implementation
>> you're
>> using, that's fine. If you mean that it's true in general, it isn't.
>> Different implementations can and do have different sizes and alignments
>> for integer types.
>
> it is true for types used by QTcreator that has "explicit" fixed
> byte-width types for 1,2,4,8 bytes.
> They are likely some typedefs defined in math.h
Not in <math.h>.
The code you posted above uses int32_t and int8_t which are defined in
<cstdint> / <stdint.h>. Their sizes and ranges are guaranteed by the
C++ language definition (by reference to the C standard). Their
alignments are not.
Qt has similar typedefs qintN and quintN, for N = 8, 16, 32, 64.
The Qt project was started in 1991, before <cstdint> / <stdint.h>
was available. Presumably if Qt were being created from scratch now,
it would just use the standard types.
A N-byte integer type often requires N-byte alignment, but it's not
required. For example, 32-bit x86 systems typically use 4-byte
alignment for 8-byte integers. For most purposes, you as a programmer
don't need to know the alignment requirements for integer types; just
let the compiler take care of it.
--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for XCOM Labs
void Void(void) { Void(); } /* The recursive call of the void */
Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
strange error (QT Creator 4.12.2, based on QT creator 5.14.2) MarioCPPP <NoliMihiFrangereMentulam@libero.it> - 2023-03-02 17:25 +0100
Re: strange error (QT Creator 4.12.2, based on QT creator 5.14.2) MarioCPPP <NoliMihiFrangereMentulam@libero.it> - 2023-03-02 17:27 +0100
Re: strange error (QT Creator 4.12.2, based on QT creator 5.14.2) Bo Persson <bo@bo-persson.se> - 2023-03-02 17:44 +0100
Re: strange error (QT Creator 4.12.2, based on QT creator 5.14.2) Tim Rentsch <tr.17687@z991.linuxsc.com> - 2023-03-05 08:20 -0800
Re: strange error (QT Creator 4.12.2, based on QT creator 5.14.2) Andrey Tarasevich <andreytarasevich@hotmail.com> - 2023-03-02 09:44 -0800
Re: strange error (QT Creator 4.12.2, based on QT creator 5.14.2) MarioCPPP <NoliMihiFrangereMentulam@libero.it> - 2023-03-02 23:37 +0100
Re: strange error (QT Creator 4.12.2, based on QT creator 5.14.2) Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2023-03-02 17:03 -0800
Re: strange error (QT Creator 4.12.2, based on QT creator 5.14.2) MarioCPPP <NoliMihiFrangereMentulam@libero.it> - 2023-03-03 13:22 +0100
Re: strange error (QT Creator 4.12.2, based on QT creator 5.14.2) Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2023-03-03 09:29 -0800
Re: strange error (QT Creator 4.12.2, based on QT creator 5.14.2) MarioCPPP <NoliMihiFrangereMentulam@libero.it> - 2023-03-04 22:53 +0100
csiph-web