[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Nano-devel] Const char * changes

From: Chris Allegretta
Subject: Re: [Nano-devel] Const char * changes
Date: Thu, 13 Feb 2003 14:29:16 -0800
User-agent: Mutt/

On Thu, Feb 13, 2003 at 03:14:04PM -0500, David Benbennick wrote:
> Chris,
> 20 hours ago you committed a change to global.c and winio.c, making lots
> of strings "char *" that used to be "const char *".  I guess the reason
> was that on some systems, the Curses waddstr() function takes a "char *"
> instead of a const string.  So for example on Solaris, there are a few
> warnings about discarding qualifiers.
> I think this might not be a great solution.  Modifying string constants
> like "Chris Allegretta" will cause a segfault, so the waddstr() function
> had better act like it gets a "const char *".  Also, on ncurses systems
> where waddstr() is declared correctly, you now get a lot of warnings with
> the -Wwrite-strings option to gcc.  -Wwrite-strings warns about
> potentially writing to a constant string.
> It seems to me much cleaner to use "char *" only for malloc()ed strings,
> which have to be freed, and to use "const char *" for literal strings,
> which can't be modified anyway.

Okay, I didn't know about this flag, the man page forgcc is rather funny
as it implies the flag is just a pain in the ass and shouldn't be used. 
My goal was to get the System V compilers to stop complaining about the
const being discarded, but print out errors just including their own
header files, so I wont bend over backwards for them.  You have a good
point, I reverted the behavior.  Please let me know if I missed

Chris A
Chris Allegretta

"Share and Enjoy" - Douglas Adams, 1952 - 2001

reply via email to

[Prev in Thread] Current Thread [Next in Thread]