This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
static member in template class
- To: egcs-bugs at cygnus dot com
- Subject: static member in template class
- From: Ulrich Drepper <drepper at cygnus dot com>
- Date: 03 Nov 1998 14:50:02 -0800
- Reply-To: drepper at cygnus dot com (Ulrich Drepper)
This is with a quite recent egcs version. Compiling the program below with
gcc -c y.cc
leads to the following message:
y.cc:11: conflicting types for `int foo<int>::bar[0]'
y.cc:8: previous declaration as `int foo<int>::bar[0]'
When compiled with
gcc -c y.cc -DN=1
There is no problem.
--
---------------. drepper at gnu.org ,-. 1325 Chesapeake Terrace
Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA
Cygnus Solutions `--' drepper at cygnus.com `------------------------
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#ifndef N
# define N 0
#endif
template<class T>
struct foo
{
static T bar[N];
};
template<> int foo<int>::bar[N];
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~