neville bonwit

CW7.0 Pro: MCF52223: Static Const Initialization: Error "Illegal constant expression"

Discussion created by neville bonwit on Apr 7, 2008
Latest reply on Apr 8, 2008 by Neville Bonwit

Hello,

I'm getting a strange compiler error.  My code (located in a header file) is as follows:

namespace myNamespace
{
 class Globals
    {
     public:  
         static const double myDouble= 6.9;
         static const int myInt= 6;
         ...
    };
}

I get the compiler error "Illegal constant expression" on the line "static const double myDouble= 6.9;", but not on the line with " static const int myInt= 6;".  In fact, the compiler gives that error for all doubles, but integers, shorts, and bools seem to be fine

Any help would be appreciated.

Thanks,
Neville



Message Edited by nbonwit on 2008-04-07 06:32 AM

Outcomes