<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<div class="moz-cite-prefix">Tak jsem udelal jeste pokus a skutecne
to asi zarovnava struktury a jejich velikosti na 64b. Resenim je
pridat 32b vypln pred CRC a je to vsechno delitelne 8 a v poradku.
Dobre vedet ;-)</div>
<div class="moz-cite-prefix"><br>
</div>
<div class="moz-cite-prefix">
<div
style="color: #cccccc;background-color: #1f1f1f;font-family: Consolas, 'Courier New', monospace;font-weight: normal;font-size: 14px;line-height: 19px;white-space: pre;">
<div><span style="color: #569cd6;">typedef</span><span
style="color: #cccccc;"> </span><span style="color: #569cd6;">struct</span><span
style="color: #cccccc;"> {</span></div><div><span
style="color: #cccccc;"> </span><span style="color: #569cd6;">union</span><span
style="color: #cccccc;"> {</span></div><div><span
style="color: #cccccc;"> </span><span
style="color: #569cd6;">struct</span><span style="color: #cccccc;"> {</span></div><div><span
style="color: #cccccc;"> </span><span
style="color: #4ec9b0;">uint32_t</span><span
style="color: #cccccc;"> </span><span style="color: #9cdcfe;">index</span><span
style="color: #cccccc;">;</span><span style="color: #6a9955;"> // index of configuration, count of writes</span></div><div><span
style="color: #cccccc;"> </span><span
style="color: #569cd6;">int</span><span style="color: #cccccc;"> </span><span
style="color: #9cdcfe;">gsm_preffered_speed</span><span
style="color: #cccccc;">;</span><span style="color: #6a9955;"> // module GSM baudrate </span></div><div><span
style="color: #cccccc;"> </span><span
style="color: #569cd6;">char</span><span style="color: #cccccc;"> </span><span
style="color: #9cdcfe;">gsm_apn</span><span
style="color: #cccccc;">[</span><span style="color: #b5cea8;">32</span><span
style="color: #cccccc;">];</span><span style="color: #6a9955;"> // module GSM APN</span></div><div><span
style="color: #cccccc;"> </span><span
style="color: #569cd6;">char</span><span style="color: #cccccc;"> </span><span
style="color: #9cdcfe;">car_ident</span><span
style="color: #cccccc;">[</span><span style="color: #b5cea8;">8</span><span
style="color: #cccccc;">];</span><span style="color: #6a9955;"> // car identification</span></div><div><span
style="color: #cccccc;"> </span><span
style="color: #569cd6;">char</span><span style="color: #cccccc;"> </span><span
style="color: #9cdcfe;">car_aeskey</span><span
style="color: #cccccc;">[</span><span style="color: #b5cea8;">65</span><span
style="color: #cccccc;">];</span><span style="color: #6a9955;"> // 256b -> 64 chars hex encoded</span></div><div><span
style="color: #cccccc;"> </span><span
style="color: #4ec9b0;">app_data_reservation_t</span><span
style="color: #cccccc;"> </span><span style="color: #9cdcfe;">reservation</span><span
style="color: #cccccc;">;</span><span style="color: #6a9955;"> // reservation data</span></div><div><span
style="color: #cccccc;"> </span><span
style="color: #4ec9b0;">int32_t</span><span
style="color: #cccccc;"> </span><span style="color: #9cdcfe;">gps_last_latitude</span><span
style="color: #cccccc;">;</span><span style="color: #6a9955;"> // car last known latitude, *10^7 (GPS_FIXP_MULT)</span></div><div><span
style="color: #cccccc;"> </span><span
style="color: #4ec9b0;">int32_t</span><span
style="color: #cccccc;"> </span><span style="color: #9cdcfe;">gps_last_longitude</span><span
style="color: #cccccc;">;</span><span style="color: #6a9955;"> // car last known longitude, *10^7 (GPS_FIXP_MULT)</span></div><div><span
style="color: #cccccc;"> </span><span
style="color: #569cd6;">double</span><span style="color: #cccccc;"> </span><span
style="color: #9cdcfe;">x</span><span style="color: #cccccc;">;</span></div><div><span
style="color: #cccccc;"> </span><span
style="color: #569cd6;">double</span><span style="color: #cccccc;"> </span><span
style="color: #9cdcfe;">y</span><span style="color: #cccccc;">;</span></div><div><span
style="color: #cccccc;"> };</span></div><div><span
style="color: #cccccc;"> </span><span
style="color: #4ec9b0;">uint8_t</span><span
style="color: #cccccc;"> </span><span style="color: #9cdcfe;">ba</span><span
style="color: #cccccc;">[</span><span style="color: #569cd6;">CFG_DATA_LEN</span><span
style="color: #cccccc;"> </span><span style="color: #d4d4d4;">-</span><span
style="color: #cccccc;"> </span><span style="color: #b5cea8;">8</span><span
style="color: #cccccc;">];</span></div><div><span
style="color: #cccccc;"> };</span></div><div><span
style="color: #cccccc;"> </span><span style="color: #4ec9b0;">uint32_t</span><span
style="color: #cccccc;"> </span><span style="color: #9cdcfe;">padd64</span><span
style="color: #cccccc;">;</span></div><div><span
style="color: #cccccc;"> </span><span style="color: #4ec9b0;">uint32_t</span><span
style="color: #cccccc;"> </span><span style="color: #9cdcfe;">crc32</span><span
style="color: #cccccc;">;</span></div><div><span
style="color: #cccccc;">} </span><span style="color: #4ec9b0;">app_data_cfg_t</span><span
style="color: #cccccc;">;</span></div>
<div><span style="color: #569cd6;">static_assert</span><span
style="color: #cccccc;"> (</span><span style="color: #569cd6;">sizeof</span><span
style="color: #cccccc;">(</span><span style="color: #4ec9b0;">app_data_cfg_t</span><span
style="color: #cccccc;">) </span><span style="color: #d4d4d4;">==</span><span
style="color: #cccccc;"> </span><span style="color: #569cd6;">CFG_DATA_LEN</span><span
style="color: #cccccc;">);</span></div>
</div>
</div>
<div class="moz-cite-prefix"><br>
</div>
<div class="moz-cite-prefix">Dne 11.03.2024 v 21:09 Jan Waclawek
napsal(a):<br>
</div>
<blockquote type="cite"
cite="mid:PC1952024031121093306662404e5fb@wekPC">
<pre class="moz-quote-pre" wrap="">sizeof(
typedef struct {
uint8_t a;
uint8_t b;
uint16_t c;
uint32_t d;
double x;
};
) = 16 takze asi to zarovnanie co ste pisali.
Tak som vyskusal aj
sizeof(
typedef struct {
double x;
uint8_t a;
uint8_t b;
uint16_t c;
uint32_t d;
};
) = 16
Hm.
Ako vravim, ja nepoznam presne tie pravidla propagacie toho zarovanania, a
ani ich nechcem poznat.
sizeof(
typedef struct {
uint8_t a;
uint8_t b;
double x;
uint16_t c;
uint32_t d;
};
) = 24
Ale to sa dalo cakat. Takze v ramci jedneho struct sa zarovnavaju tie
premenne na svoju sirku. Mozno ten union v tom ma prsty... mozno nie. Fakt
netusim.
Ale k tomu gcc je k dispozicii aj ta najkompletnejsia dokumentacia...
(pozdravujem pravovernych Linuxakov ;-) )
wek
----- Original Message ---------------
</pre>
<blockquote type="cite">
<pre class="moz-quote-pre" wrap="">Dekuji za vysvetleni, clovek se stale neco uci... to same se tyka i int64_t?
A kdyz budu mit
struct {
uint8_t a;
uint8_t b;
uint16_t c;
uint32_t d;
doube x;
}
tak to bude na jakych offsetech ? Zatim bych cekal 0, 1, 2, 4, 8
A to zarovnani na 8 se pak tyka cele struktury?
No budu to muset prozkoumat.
</pre>
</blockquote>
<pre class="moz-quote-pre" wrap="">
_______________________________________________
HW-list mailing list - sponsored by <a class="moz-txt-link-abbreviated" href="http://www.HW.cz">www.HW.cz</a>
<a class="moz-txt-link-abbreviated" href="mailto:Hw-list@list.hw.cz">Hw-list@list.hw.cz</a>
<a class="moz-txt-link-freetext" href="http://list.hw.cz/mailman/listinfo/hw-list">http://list.hw.cz/mailman/listinfo/hw-list</a>
</pre>
</blockquote>
<p><br>
</p>
</body>
</html>