Thanks,
This also works:
file.h
const char cmdNames[]=
{
'l','i','s','t',0,
'v','e','r',0,
'h','e','l','p',0,
'f','e','e','d','b','a','c','k',0,
'e','c','h','o',0,
's','w','R','e','a','d',0,
's','w','R','e','a','d','A','l','l',0,
's','w','I','n','i','t',0,
'i','n','i','t',0,
0
};
file.c
#include "file.h"
But that puzzles me.
I had so much difficulties to find a way to get rid of multiple defines, that I ruled out this solution.
This file.h is included in many other files and the compiler does not complain.
I'm not to hot about the #define solution, because the header file is auto generated by another application, and I would have to modify the code.
extern const char cmdNames[];
this won't compile
for(i=0, k=0;i<sizeof(cmdNames);i++)
unless I specify array dimension, like
extern const char cmdNames[58];
Because complier reserved memory for this array, it should know the size of that array!
For now, I have to figure out by myself what is this array size.
Am I using sizeof() correctly ?