String constification

Francois Gouget fgouget at free.fr
Sat Apr 24 17:04:35 CDT 2004


On Sat, 24 Apr 2004, Dimitrie O. Paun wrote:

> On April 24, 2004 10:30 am, Dmitry Timoshkov wrote:
> > I prefer to not rely on a compiler's good will.
>
> To be honest, I don't much see the point of this patch myself.

Maybe the text at the beginning made it look like this is just about
'const char*' vs 'const char []'. But what it's really about is adding
const and static where appropriate.

 * const
   Causes the strings to be put into a read-only section.
   Stuff from read-only sections can be simply discarded when memory is
low instead of having to be written out to the wap file. That's because
it can be read back from the executable.

 * static
   Stops the compiler from generating code that copies strings to the
stack each time we enter the function.

Doesn't that count for anything?


> If you want to look at the constantness of strings, there was
> an effort back in Oct 2003 by Daniel Marmier to fix things up
> so that we can compile Wine with -Wwrite-strings:
>     http://www.winehq.org/hypermail/wine-devel/2003/10/0269.html

That's certainly useful too but I see this as a pretty different issue.
And you'll still get a ton of warnings if you add '-Wwrite-strings' to
gcc's options.

-- 
Francois Gouget         fgouget at free.fr        http://fgouget.free.fr/
           If it stinks, it's chemistry. If it moves, it's biology.
                  If it does not work, It's computer science.



More information about the wine-devel mailing list