RE: [Dev-C++] 'extern const' and std::vector
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Per W. <pw...@ia...> - 2003-05-01 15:16:06
|
Yes, this exists: extern const int x; However, that is a constant. The request - as I read it - was for a global variable to be const in just one file, while writeable in other files. When extern-declaring something (that is already declared somewhere else), you should declare it identical to the original declaration, and it this case the original declaration is not const. /Per W On Thu, 1 May 2003, Ioannis Vranos wrote: > > -----Original Message----- > > From: dev...@li... > > [mailto:dev...@li...] On Behalf > > Of Per Westermark > > Sent: Thursday, May 01, 2003 5:23 PM > > To: David McKen > > Cc: dev...@li... > > Subject: Re: [Dev-C++] 'extern const' and std::vector > > > > > > I'm not too good at the latest updates of the standards, but > > to the best > > of my knowledge, there is no const extern declarations. > > > Why? > > > > > Extern is just a keyword to inform the compiler that > > somewhere in another > > linking unit, the specified variable or function exists. > > However, you can > > not just lie, because when you reference the symbol, the compiler will > > insert a name-mangled reference and the linker will then fail if an > > exactly identical reference isn't available somewhere in one of the > > included object or library files. > > > If you do extern int x; > > > and you do not define x elsewhere, it is considered a definition. The same > applies for > > extern int x=1; > > > It is considered a definition (extern is ignored). > > > > > > Ioannis Vranos > > * Programming pages: http://www.noicys.freeurl.com > * Alternative URL 1: http://run.to/noicys > * Alternative URL 2: http://www.noicys.cjb.net > > > Anti-racism movement: http://www.positive-youthfoundation.org > Iraq Peace Pledge: http://www.peacepledge.org > > > > > ------------------------------------------------------- > This sf.net email is sponsored by:ThinkGeek > Welcome to geek heaven. > http://thinkgeek.com/sf > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > |