Code auto generation tools?
Does anyone know of tools or C libraries that might generate the following as C variable declarations:
1. static const char tables of possibly varying sizes initialized with binary data in the form of escape sequences. Eg. const char s ="\xE9a_00\0\0\0T.....";
The data is read either from binary file, or a user might provide a custom s[i] function pointer.
2. Auto generated #define PREFIX_SUFFIX[i] flag constants. reading a list of suffixes as a simple word file, and possibly accounting for a start of the flag defines.
3. Various other long repetitive declarations that can't be simulated with preprocessor commands.
#define IOMODE_READ (1<<1)
#define IOMODE_WRITE (1<<2)
Would anyone have any use for such a tool? I tried Googling for anything ready made but found nothing. I was considering to make a small C library to handle the situation, but Perl seemed a more appropriate tool for the job. Still since i can cover my needs with more or less short hack-code, it didn't seem like i should bother much.
Are sparse constant array declarations a possibility in C?
Came up with the need when i needed some compressed data within the source file.
I wasn't happy with my solution, since i dropped the compression to represent the escaped values in the char . Does anyone know a better way to do this?