This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Static Const


Paine, Thomas Asa wrote:
I am trying to declare a static const member like this...

   class RemoteManager:public Runnable{
   ...
    public:
     ...
-->  static const char MANAGEMENT_INTERFACE[] = "127.0.0.1";
     ...
   };

but when compiling, keep getting this...

g++ -g -Wno-deprecated -I /downloads/xerces/xerces-c-src_2_3_0/include/
-c remotemanager.cpp
In file included from remotemanager.cpp:7:
remotemanager.h:15: invalid in-class initialization of static data
member of
   non-integral type `const char[]'
make: *** [remotemanager.o] Error 1

I'm missing something small here, but I'm not seeing it.  Seems to be
object related because the same line of code in a simple main() function
works fine.  Thoughts?
Read section 9.4.2 paragraph 4 of the std

I'll precis it for you 'in-class initialization of static data member of
non-integral types are not permitted' :)

nathan

--
Nathan Sidwell    ::   http://www.codesourcery.com   ::     CodeSourcery LLC
         The voices in my head said this was stupid too
nathan@codesourcery.com    ::     http://www.planetfall.pwp.blueyonder.co.uk



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]