🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #2415

Re: Can I declare private constants?

#2415
From: Ulf Schuenemann
Date: Fri, 03 Nov 1995 19:01
47 lines
2469 bytes

|martelli@cadlab.cadlab.it (Alex Martelli) wrote:
[..]
|> Suppose the program, in various different source files, takes the address
|> &X::fifty, and saves it in int* variables; then, at some later points,
|> those variables are compared for equality of their contents.  We want
|> to ensure that such equality holds.  That the _contents_ of X::fifty
|> are defined in the header seen by each such source file has obviously
|> no relevance to this -- the _location_ of it must also be defined,
|> and, clearly, it will have to be in exactly one place to guarantee
|> the equality holds...

AFAIK there was a similas problem with the address of inline
memberfunctions. It was solved by the concept of "extern inline",
which now is also available for non-memberfunctions.
Inline memberfunctions are always "extern inline".

And there is the concept of "extern const" which guarantees that
even in different translation units the address is the same.
If you think of const static datamembers as "extern const" (analogously
to inline memberfunctions as "extern inline"), then

	struct A {
		static const int	i = 1;
	}

could be treated like

	const int	A__i = 1;

This would make a separate definition of A::i superflous while
still guaranteeing the equivalence of addresses (= external linkage).


Ulf Schuenemann

--------------------------------------------------------------------
 ,_.   Ulf Schuenemann
#,  \  Fakultaet fuer Informatik, Technische Universitaet Muenchen, Germany.
 |   > email: schuenem@informatik.tu-muenchen.de
 v=-<  WWW:   http://hphalle2.informatik.tu-muenchen.de/~schuenem/

---
[ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Technical Details
Message-ID: <47dika$2sv@sunsystem5.informatik.tu-muenchen.de>
Path: arc1-ca.pugleaf.net!128.32.155.1!matt
References: <9509118134.AA813443405@intugate.intuit.com> <9528514.26968@mulga.cs.mu.OZ.AU> <s6burc43zt.fsf@kirk.mlc-ratingen.de> <martelli.814356512@cadlab> <46f8lv$oct@ixnews6.ix.netcom.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!128.32.155.1!matt
From: schuenem@informatik.tu-muenchen.de (Ulf Schuenemann)
Newsgroups: comp.std.c++
Subject: Re: Can I declare private constants?
Date: 03 Nov 1995 19:01:49 GMT
Organization: Technische Universitaet Muenchen, Germany
Approved: matt@physics2.Berkeley.EDU (Matt Austern)
Message-ID: <47dika$2sv@sunsystem5.informatik.tu-muenchen.de>
References: <9509118134.AA813443405@intugate.intuit.com>  <9528514.26968@mulga.cs.mu.OZ.AU> <s6burc43zt.fsf@kirk.mlc-ratingen.de> <martelli.814356512@cadlab> <46f8lv$oct@ixnews6.ix.netcom.com>
NNTP-Posting-Host: physics2.berkeley.edu