Article View: comp.std.c++
Article #1424Re: initialized 'global' (extern) char arrays
From: Fergus James HENDERSON
Date: Fri, 08 Jan 1993 01:23
Date: Fri, 08 Jan 1993 01:23
32 lines
1587 bytes
1587 bytes
jimlynch@netcom.com (Jim Lynch) writes: >I am given to understand that the storage allocated by > >char *x = "abcde" ; > >is not writable. Correct. >The reason I ask is that I used such a construct in gcc-2.3.2 ... [example omitted] >... Shouldn't the compiler have warned me? With gcc, use the -Wwrite-strings option. Here's an extract from the manual: -Wwrite-strings Give string constants the type const char[length] so that copying the address of one into a non-const char * pointer will get a warning. These warnings will help you find at compile time code that can try to write into a string constant, but only if you have been very careful about using const in declarations and proto- types. Otherwise, it will just be a nuisance; this is why we did not make `-Wall' request these warnings. -- Fergus Henderson fjh@munta.cs.mu.OZ.AU This .signature virus is a self-referential statement that is true - but you will only be able to consistently believe it if you copy it to your own .signature file!
Technical Details
Message-ID:
<9300812.4657@mulga.cs.mu.OZ.AU>Path:
arc1-ca.pugleaf.net!sparky!uunet!munnari.oz.au!cs.mu.OZ.AU!munta.cs.mu.OZ.AU!fjhReferences:
<1993Jan7.032458.21941@netcom.com>Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c++ Path: arc1-ca.pugleaf.net!sparky!uunet!munnari.oz.au!cs.mu.OZ.AU!munta.cs.mu.OZ.AU!fjh From: fjh@munta.cs.mu.OZ.AU (Fergus James HENDERSON) Subject: Re: initialized 'global' (extern) char arrays Message-ID: <9300812.4657@mulga.cs.mu.OZ.AU> Sender: news@cs.mu.OZ.AU Organization: Computer Science, University of Melbourne, Australia References: <1993Jan7.032458.21941@netcom.com> Date: Fri, 8 Jan 1993 01:23:49 GMT Lines: 32