Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #70011

[QT creator on "nix"] - "outer" padding within arrays of structures - was getting a strict 8 bit (1 byte) array with no padding

From Soviet_Mario <SovietMario@CCCP.MIR>
Newsgroups comp.lang.c++
Subject [QT creator on "nix"] - "outer" padding within arrays of structures - was getting a strict 8 bit (1 byte) array with no padding
Date 2019-11-23 13:17 +0100
Organization A noiseless patient Spider
Message-ID <qrb80f$9t4$1@dont-email.me> (permalink)

Show all headers | View raw


I have realized I don't know an aspect of padding vs packing 
management.

In the other thread I have been explained of the aspects of 
padding/packing INSIDE a given structure/class/union and 
similar.

But now I realize I know nothing for sure about packing in 
between different element within arrays of such 
structure/class/union and similar.

for a start I haven't found a documentation about the 
#pragma pack directive applied to a whole array

is it possible (and how) to suggest the compiler to pack 
items ? (*)
Are there differences in the outcome of such hints depending 
on actual size of the packed structures ?
I am figuring out a packed struct of ODD total size, when 
allocated in an array, it could lead to either non packed 
array or to addresses in ODD/EVEN pattern (is it possible ? 
Non asking if efficient, just possible).


secondly, how much is it, reasonably, the no-padding 
threshold in an array of class/struct/union objects ?

There is some criterion, preferably less restrictive than 
"powers of two" size of objects" ?

I feel quite sure that 64 bit  multiple are packed without 
any suggestion.
But, for example, 32 bit ? 16 bit ?

The hardware per se has no problem : in fact it can manage 
COMPACT arrays of native types (int, short int) without 
memory waste. I would hope that the same could hold for 
structured types of the same size, but not so sure.
What is the truth ?


Could packing (assuming it is possible to force the compiler 
to do it) lead to addressing problems (of the contained data 
member) ?
I am not speaking about SLOWING problems, but strictly 
crashes or silent wrong addressing or ... dunno !

TY



-- 
1) Resistere, resistere, resistere.
2) Se tutti pagano le tasse, le tasse le pagano tutti
Soviet_Mario - (aka Gatto_Vizzato)

Back to comp.lang.c++ | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

[QT creator on "nix"] - "outer" padding within arrays of structures - was getting a strict 8 bit (1 byte) array with no padding Soviet_Mario <SovietMario@CCCP.MIR> - 2019-11-23 13:17 +0100
  Re: [QT creator on "nix"] - "outer" padding within arrays of structures - was getting a strict 8 bit (1 byte) array with no padding Keith Thompson <kst-u@mib.org> - 2019-11-23 12:35 -0800

csiph-web