I declare an array of structs and want to declare a second into which I can make a copy in order to re-initialze the structure at the start of each unit test.
So, I declare in 2 header files
extern peripheralsArray_t Peripherals;
extern peripheralsArray_t DefaultPeripherals;
and in 2 c files
peripheralsArray_t Peripherals =
{... init values };
peripheralsArray_t DefaultPeripherals;
BUT, when I try to assign DefaultPeripherals = Peripherals; the GCC comiler (under Cygwin) says
error: incompatible types when assigning
to type ‘peripheralsArray_t’ from type ‘struct _peripherals *’
Why does it think that Peripherals is a pointer?
Assuming that your type names are descriptive and
peripheralsArray_treally is an array.C does not support array assignment, which is what you are trying to do.
So the compiler see a array in a RHS context and deduces that it should decay to a pointer, which then has the wrong type.