🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.help
Article #53591

Question on static const volatile

#53591
From: Paul D. Smith
Date: Tue, 01 Oct 1991 12:35
38 lines
2461 bytes
GCC:    gcc version DG 1.37 (88open OCS/BCS, DG-1.37.31, Apr 25 1991)
OS:     DG/UX
HOST:   DG AViiON

I need to include a what(1) string in an executable.  I want to
include it by making a declaration like this:

-------------------------------------------------------------------------------
static const char *const what_string = "File foobar";
-------------------------------------------------------------------------------

When I do this, I of course get an error from gcc stating that
variable what_string is defined but never used.  I know that the
standard solution to this problem is to declare a local variable
somewhere and initialize it to point to what_string, but I thought
there would be a more elegant way under ANSI C.  It seems to me that
if I declare what_string to be a volatile then, according to ANSI, GCC
can make no assumptions about how and/or when what_string is used, and
should therefore stop giving me that error.

However, no matter how I add volatile keywords (make the string
volatile or the pointer volatile, or both) I always get the warning
about what_string defined but not used.

Is this correct under ANSI?  I know that volatile is highly
implementation-dependant, but it *is* supposed to tell the compiler
not to assume anything about memory declared as volatile, and this
warning seems to me to fall in this category.  Any opinions or
suggestions?

                                                                paul
-----
 ------------------------------------------------------------------
| Paul D. Smith                          | pds@lemming.webo.dg.com |
| Data General Corp.                     |                         |
| Network Systems Development Division   |   "Pretty Damn S..."    |
| Open Network Systems Development       |                         |
 ------------------------------------------------------------------
Technical Details
Message-ID: <9110012035.AA09012@lemming.webo.dg.com>
Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!cis.ohio-state.edu!lemming.webo.dg.com!pds

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 11318c,67357a4b9faaf165,start
X-Google-Attributes: gid11318c,public
X-Google-ArrivalTime: 1991-10-02 20:39:38 PST
Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!cis.ohio-state.edu!lemming.webo.dg.com!pds
From: pds@lemming.webo.dg.com (Paul D. Smith)
Newsgroups: gnu.gcc.help
Subject: Question on static const volatile
Message-ID: <9110012035.AA09012@lemming.webo.dg.com>
Date: 1 Oct 91 12:35:37 GMT
Sender: daemon@cis.ohio-state.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 38