A file has a series of void declarations used as void*
as follows:
extern void __flash_rwdata_start;
...
initialize(&__flash_rwdata_start,
...
which are provided solely by the linker script as symbols referring to binary partitioning as follows (ie a pointer):
PROVIDE (__flash_rwdata_start = LOADADDR(.rwdata));
And this generates the following warning:
file.c:84:19: warning: taking address of expression of type 'void' [enabled by default]
As per the answer to Why has GCC started warning on taking the address of a void expression?, I've changed this as follows (the function which takes the pointers uses an unsigned long*
anyway):
extern unsigned long __flash_rwdata_start;
Now it occurs to me that the original definition had an implication of zero (or undefined) size, whereas the current definition does not, and unlike the answer to Why has GCC started warning on taking the address of a void expression? there is no "real underlying data type" that makes any logical sense.
Essentially I've defined a pointer that is valid, but does not point to a valid value, and thus it would be invalid to dereference.
Is there a safer or preferable way to avoid the warning, but without the idea of space being allocated, that can't be dereferenced?
One idea that comes to mind is to make the object's type be an incomplete struct, like:
extern struct never_defined __flash_rwdata_start;
This way the address will be valid, but, as long as the type is never defined, not dereferenceable.