I am working on some legacy C code that has this unusual array initialization:
uint32_t defsMB40000[REG40000_SIZE] =
{
#include "modbusDefs40000.h"
};
The header file is a list of comma separated numbers and comments. I have never seen this construct before but it does seem to work correctly. Would it not be better to have inside the header:
uint32_t defsMB40000[REG40000_SIZE] =
{
0,
0xFF,
...
};
and then
#include "modbusDefs40000.h"
in the .c file?
I suspect the reason it even exists is that the header file is created by a python script. I would appreciate your comments on this idiom and if you have seen the likes of it.
Thanks,
jh