[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: static const int variable needs init value

From: Greg Hudson <ghudson_at_mit.edu>
Date: 2001-12-05 18:48:56 CET

On Wed, 2001-12-05 at 11:22, Matt Kraai wrote:
> On Wed, Dec 05, 2001 at 02:19:38AM -0800, Max Okumoto wrote:
> > * subversion/subversion/libsvn_ra_dav/commit.c
> > static const int variable needs init value even if it is zero.
>
> Why? Aren't non-automatic variables zeroed by default?

They are. A compiler warning about "static const int foo;" is full of
it. And the native Solaris cc doesn't give me any warning:

small-gods% cat foo.c
static const int blah;
small-gods% cc -V -c foo.c
cc: Sun WorkShop 6 update 1 C 5.2 2000/09/11
acomp: Sun WorkShop 6 update 1 C 5.2 2000/09/11
small-gods%

So, I'm not sure what Max is seeing.

(Stylistically, I would favor an explicit "= 0" in most cases where
you'd use a "static const int" declaration. In this case, though, I
would actually favor getting rid of the "const", if I couldn't find a
good way to do without the variable entirely. commit.c is doing
something really odd with singleton_delete_prop, such that nothing cares
about its value. Asserting that the value is constant has no particular
meaning.)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sat Oct 21 14:36:51 2006

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.