🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Seth C. Goldstein Sat, 21 Nov 1992 05:49
gcc 2.3.1 bug with templates in c++
#1458
Author: Seth C. Goldstein
Date: Sat, 21 Nov 1992 05:49
51 lines
1473 bytes
Machine:	sparc
Version:	gcc version 2.3.1
OS:		SunOS Release 4.1.2
problem:	
1 - The methods in a parameterized class are not implemented by the compiler
    if the definitions are not included in the class definition.  For
    example:

	//////////////////////////////// bar.h
	template<class T>
	class Bar
	{
		T data;
	public:
		inline Bar(T i);
		T get(void);
	};
	
	
	template<class T> inline 
	Bar<T>::Bar(T i)
	{
		data = i;
	}
	//////////////////////////////// EOF
	//////////////////////////////// bar.C
	#include "bar.h"
	
	template<class T> T
	Bar<T>::get(void)
	{
		return data;
	}
	//////////////////////////////// EOF
	//////////////////////////////// user.C
	#include <stdio.h>
	#include "bar.h"
	
	main()
	{
		Bar<int> bi(2);
	
		printf("%d\n", bi.get());
	}
	//////////////////////////////// EOF

    when compiled with: gcc-2.3.1 -o test bar.C user.C generates the
    following linktime error:

	ld: Undefined symbol 
	   _get__t3Bar1Zi 
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads