Problem with static in templates

Marc Winter
Mon Jan 11 05:19:00 GMT 1999


if I compile the following "":


template <class T>
class A {
        static int a;
        A() {a=0;}
        void in(T i) {a=i;}

template <class T> int A<T>::a = 0;

int main (void)
        A<int> b;;

        return 0;



	g++ -o test.exe

I get:
	ld: 0711-317 ERROR: Undefined symbol: A<int>::a
	ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more
	collect2: ld returned 8 exit status
I am using (from g++ -v):

	Reading specs from /usr/net/lib/gcc-lib/rs6000-ibm-aix4.2.1.0/egcs-2.91.57/specs
	gcc version egcs-2.91.57 19980901 (egcs-1.1 release)

When I omit the init-parameter of a there are no errors.

Is there anything I can do about this error without greater changes on
the code?


Marc Winter				FGNN GHK Uni-Kassel



More information about the Gcc-bugs mailing list