N
Noob
Hello,
Consider the following code, where I define an automatic array.
void foo(void)
{
uint8_t arr[64];
}
How will 'arr' be aligned?
I suppose 'arr' could start on an odd address?
(i.e. "aligned" to an uint8_t i.e. not aligned.)
If I need the buffer to be aligned to 32 bits, do I have to write
something along the lines of ...
void foo(void)
{
uint32_t temp[64/4];
uint8_t *arr = (uint8_t *)temp;
}
Is this valid C? (No UB / I-DB / general-nastyness)
Are things different if I malloc the array?
uint8_t *arr = malloc(64);
Regards.
Consider the following code, where I define an automatic array.
void foo(void)
{
uint8_t arr[64];
}
How will 'arr' be aligned?
I suppose 'arr' could start on an odd address?
(i.e. "aligned" to an uint8_t i.e. not aligned.)
If I need the buffer to be aligned to 32 bits, do I have to write
something along the lines of ...
void foo(void)
{
uint32_t temp[64/4];
uint8_t *arr = (uint8_t *)temp;
}
Is this valid C? (No UB / I-DB / general-nastyness)
Are things different if I malloc the array?
uint8_t *arr = malloc(64);
Regards.