Mail Archives: djgpp-workers/1998/02/04/10:29:49
On Tue, 3 Feb 1998, DJ Delorie wrote:
> 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).
Yeah, I figured this would be the problem. It's hardly worth the hassle
to have two identical arrays, I think. The question is, which one is
more popular? To me it seemed that the version without the leading
underscore is.
Is the _sys_siglist[] variety found on SysV Unices? What does SGI use?
At least Sun/Solaris here has sys_siglist, but that might be for
compatibility with SunOS 4.x which is BSD.
> You can cast a string *to* const, but it's harder to cast it away from
> const.
The problem is that if I say ``char *foo = "foobar";'', GCC treats foo
as const char *, and then complains when I say ``sys_siglist[i] = foo;''
because sys_siglist is char [], not const char []. I couldn't find an
easy way out of this, and I didn't want to use unconst since it is not
really needed here.
> 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[].
That was the other reason I decided not to worry about this. Both Emacs
and Make (two programs that use sys_siglist[]) declare it as non-const.
- Raw text -