delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1998/02/03/08:40:25

Date: Tue, 3 Feb 1998 08:40:23 -0500 (EST)
Message-Id: <199802031340.IAA28128@delorie.com>
From: DJ Delorie <dj AT delorie DOT com>
To: eliz AT is DOT elta DOT co DOT il
CC: eldredge AT ap DOT net, djgpp-workers AT delorie DOT com
In-reply-to: <Pine.SUN.3.91.980203121652.21682d-100000@is> (message from Eli
Zaretskii on Tue, 3 Feb 1998 12:17:17 +0200 (IST))
Subject: Re: NSIG ?

> 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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019