OT arm-gcc hadanka
Jaroslav Buchta
jaroslav.buchta na hascomp.cz
Pondělí Prosinec 29 16:45:22 CET 2014
A nezalezi i na typu jadra procesoru? Myslim, ze nektere verze snaseji
nezarovnany word, nektere ne...
Dne 29. 12. 2014 v 16:35 Miroslav Šinko napsal(a):
> On 29.12.2014 16:26, Jan Waclawek wrote:
>>> 8 a 16?
>>
>> No, to by som bol prosil, preto je tam ten __attribute__((packed))
>> (aligned
>> v tomto pripade je naozaj ignorovane, ako manual slubuje).
>>
>> Lenze...
>>
>>> 10, 20?
>>
>> Ved prave.
>>
>>
>>>
>>> S ARM-ami nerobim, predpokladam defaultne zarovnanie na 4 byty.
>>
>>
>> No, lenze potom by sizeof(TBar) mal byt prinajmensom nasobok 4, nie?
>
> Preco? TBar mas explicitne zarovnany na 1. Co nemas explicitne
> zarovnane je union, ten bude zarovnavany na 4B. Jeho velkost je dana
> vacsou polozkou, teda "uint16_t c[3]". 16-bit polozka sama osebe nema
> byt preco natahovana na 4B, teda velkost c[3] je 6B. Ale union ako
> celok MUSI byt doplneny paddingom na 4B zarovnanie, tu na 8B. No a v
> TBar to spolu s "uint16_t a" vyjde na 10B.
>
>> Takze druhe kolo, tipnite si, kolko je offsetof(TBar, b).
>
> Tu by nemal byt problem: 2
>
> miro
>
>> wek
>>
>>
>>
>>
>>>
>>> On 29.12.2014 13:34, Jan Waclawek wrote:
>>>> arm-none-eabi-gcc (GNU Tools for ARM Embedded Processors) 4.8.3
>>>> 20131129
>>>> (release) [ARM/embedded-4_8-branch revision 205641]
>>>>
>>>> c:/PROGRA~1/ARMTools/launchpad.net_gcc-arm-embedded/bin/arm-none-eabi-gcc
>>>>
>>>> -c -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -mthumb -I.
>>>> -Wpadded -MD -MP -MF .dep/ch.o.d ch.c -o objdir/ch.o
>>>>
>>>>
>>>> Aka je vysledna hodnota a a b?
>>>>
>>>> wek
>>>>
>>>>
>>>> #include<stdint.h>
>>>>
>>>> typedef struct __attribute__((packed, aligned(1))) {
>>>> uint16_t a;
>>>> union {
>>>> uint32_t b;
>>>> uint16_t c[3];
>>>> };
>>>> } TBar;
>>>>
>>>> typedef struct __attribute__((packed)) {
>>>> TBar a;
>>>> TBar b;
>>>> } TFoo;
>>>>
>>>>
>>>> const uint32_t a = sizeof(TBar);
>>>> const uint32_t b = sizeof(TFoo);
>>>>
>>>> int main(void) {
>>>> }
>>>>
> _______________________________________________
> HW-list mailing list - sponsored by www.HW.cz
> Hw-list na list.hw.cz
> http://list.hw.cz/mailman/listinfo/hw-list
---
This email has been checked for viruses by Avast antivirus software.
http://www.avast.com
Další informace o konferenci Hw-list