In file1.c, I have the array
const uint8 myArray[] =
{
0x4b, 0x28, 0x05, 0xbf,
...
0xff, 0xff, 0xff, 0xff
};
In file2.c, I need to use the array as follows:
uint8* buffer = myArray;
uint32 length = ???
I've tried length = sizeof(myArray), but this results in the following error:
error: invalid application of ‘sizeof’ to incomplete type ‘const uint8[] {aka const unsigned char[]}’.
Since it is constant, I could physically count the number of entries, but I need to do it programmatically because this constant is likely to change further on in development.
#definefor the size of the array....#define ARRAY_SIZE xthenconst uint8 myArray[ARRAY_SIZE] = { ... };constmyArrayLengthinfile1.c, you should be able to usesizeofthere.myArrayis not visible infile2.c. Only the declaration is (though it seems you left that out in your question?), so you cannot get the size.