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]

Clarification on unnamed types...


Hi,

Can someone clarify why this code snippet gets the following error (using
3.0.3 on Solaris 2.7):

> g++ -W -Wall -Wpointer-arith -pipe -g -frepo -x c++ -c foo.h
foo.h:29: conflicting types for `T si::Val__<T>::per_[nBaseDims]'
foo.h:13: previous declaration as `T si::Val__<T>::per_[nBaseDims]'

Is it legal to use an unnamed enumeration this way? When I replace the
enumeration with a const int it compiles fine. Is this a bug in gcc
(compiles fine using the KAI compiler, but could be a bug in KAI)?

Tom


<<snip foo.h>>
namespace si  {

//  const int nBaseDims = 7 + 1;
  enum { nBaseDims = 7 + 1 };

  template< class T = double >
  class Val__  {

  protected:

    typedef T  Rep;
    static Rep          per_[nBaseDims];

    Rep n_;


  public:

    Val__( Rep n = Rep(0) ) : n_( n )  { }


  };  // class Val__<>


  // Default values for static member:
  //
  template< class T >
  typename Val__<T>::Rep  Val__<T>::per_[nBaseDims] =  {
    Rep( 1.0 ),
    Rep( 0.0 ),
    Rep( 0.0 ),
    Rep( 0.0 ),
    Rep( 0.0 ),
    Rep( 0.0 ),
    Rep( 0.0 ),
    Rep( 0.0 )
  };


}  // namespace si


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