This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Clarification on unnamed types...
- From: "Thomas J Amato" <Thomas_J_Amato at raytheon dot com>
- To: gcc at gcc dot gnu dot org, gcc-help at gcc dot gnu dot org
- Date: Wed, 1 May 2002 08:25:45 -0400
- Subject: 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