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]

Re: Problem with class operators.


Hi all (again),

Xcode again. Seem like gcc optimize methods away, which are needed by code
in another file. This means, I get Link errors.

I ll try to discribe this as good as I could without the whole code :

File1.h
	template <class t>
	class a
	{
		...
		virtual bool isBig();
	}

File1.cpp
	template<class t>
	bool a<t>::isBig()
	{
		return false;
	}

	dummyfunctionfora()
	{
		a<char>	aA;
		bool		b;

		b = aA.isBig;
	}

File2.cpp
	#include "File1.h"

	...
	b = aA.isBig();
	...

What I did : template class a is defined in File1, and only be used by a
dummy function, which is not called. ( I try this that the compiler
generates the needed code). This runs fine with CW and VS. But with gcc
(xcode 2.1) this could lead into a link error.

How could I solve this ? Is there any smarter way to make sure the
template class is compiled for the types I want ? Is there a way to stop
gcc from optimize my methods away ? The normal (xcode for gcc) setting for
Optimizing I tried (different counts of link error, but never none).

Thanks,

Kristian Kratzenstein


--------------------------------------------
Kristian Kratzenstein
Gettorf

Kristian.Kratzenstein@KielNET.net
--------------------------------------------



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