I was attempting to explain to a co worker a concept and came to the realization I was incorrect in my understanding.
How are structs with arrays embedded assignable?
For example:
typedef struct {
uint8_t data[8];
} Test;
...
Test test1;
Test test2;
... some assignment to test1
test2 = test1;
I know if data was of type pointer that we would need to implement a deep copy but I'm trying to understand fully the way this works.
My though process is that as 'data' would normally be the pointer to the first element and that &data would be the address of that pointer. In the case of the struct is the struct address what the compiler is using to access the array?
Can someone explain the language mechanism that allows this. Is this just syntactic sugar for c structs? If so, why not implement direct array assignment like so...
uint8_t data[10];
uint8_t data2[10];
...
data2 = data;
Why after years of C programming am I having an existential language crisis about a mechanism I have used but never understood?