Mail Archives: djgpp-workers/1998/02/03/08:40:25
> DJ, do you think we should have both `sys_siglist' and `_sys_siglist'?
> If so, would it be okay to define the latter be a char ** which points
> to sys_siglist[0]?
This is tricky, since arrays are not pointers you'd have to have two
complete arrays (one for each name) to prevent namespace pollution. I
had to do this for the error list (what perror/strerror uses).
> You cannot say "const char *sys_siglist[]" because it is filled with
> malloc'ed strings that are modified to replace XXh with the actual
> numbers and therefore cannot themselves be `const'. `const' means you
> don't change the strings, but `put_hex_digits' does just that.
You can cast a string *to* const, but it's harder to cast it away from
const. The "const" refers to the data it points to (const char), not
the pointer itself (const *). Compare:
const char *foo; // foo=0 OK, *foo=0 BAD
char const *foo; // foo=0 BAD, *foo=0 OK
The other problem is that programs not expecting the const may not
compile if they use non-const-char-* pointers to hold the values from
_sys_siglist[].
- Raw text -