Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #14658
| From | Christian Gollwitzer <auriocus@gmx.de> |
|---|---|
| Newsgroups | comp.lang.c++ |
| Subject | Re: static constants are not local to the file they're defined. |
| Date | 2012-03-01 19:21 +0100 |
| Organization | A noiseless patient Spider |
| Message-ID | <jioen5$4ct$1@dont-email.me> (permalink) |
| References | <16464242.82.1330590524680.JavaMail.geo-discussion-forums@vbtf25> <17386272.1266.1330613495577.JavaMail.geo-discussion-forums@vbux23> |
Am 01.03.12 15:51, schrieb Luca Cerone: > Thanks for your replies. > Apparently I made something wrong before because creating > a minimal example to post here I could use the declared constant only > in mylib.cpp. > > What I don't get though is: why should I declare it static? > If I declare a simple const double variable I get the same a variable > that is only valid in mylib.cpp and not in the other files. Invisible to cpp files, but not invisible to the linker. With a usual const variable, all that neds to be done by another cpp file is to do extern const double L_COS; to access it. If L_COS is declared static, it can not be accessed from outside. Additionally, you could have multiple different L_COS variables in different translation units (cpp files) Christian
Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
static constants are not local to the file they're defined. Luca Cerone <luca.cerone@gmail.com> - 2012-03-01 00:28 -0800
Re: static constants are not local to the file they're defined. Robert Wessel <robertwessel2@yahoo.com> - 2012-03-01 02:55 -0600
Re: static constants are not local to the file they're defined. Geoff <geoff@invalid.invalid> - 2012-03-01 01:25 -0800
Re: static constants are not local to the file they're defined. Luca Cerone <luca.cerone@gmail.com> - 2012-03-01 06:51 -0800
Re: static constants are not local to the file they're defined. Christian Gollwitzer <auriocus@gmx.de> - 2012-03-01 19:21 +0100
Re: static constants are not local to the file they're defined. Robert Wessel <robertwessel2@yahoo.com> - 2012-03-01 12:21 -0600
Re: static constants are not local to the file they're defined. Luca Cerone <luca.cerone@gmail.com> - 2012-03-02 00:56 -0800
Re: static constants are not local to the file they're defined. Robert Wessel <robertwessel2@yahoo.com> - 2012-03-02 03:53 -0600
Re: static constants are not local to the file they're defined. Luca Cerone <luca.cerone@gmail.com> - 2012-03-02 02:42 -0800
csiph-web