Topic: Pbs with SUN C++ Compiler!
Author: sam@resumix.portal.com (Stephane AMARGER)
Date: Tue, 14 Jun 1994 09:51:15 GMT Raw View
I have two problems using the Sparc compiler CC-3.0.1
on a SunOS 4.1.3 1 sun4m
First problem.
_____________
Compiling a C++ source containing the following selected code:
template <class T> class MWTree ;
template <class T>
ostream& operator<<( ostream& , const MWTree<T>& );
template <class T>
class MWNode : public Info<T> {
MWNode* parent ;
MWNode* child ;
MWNode* sibling ;
public:
MWNode(T* a , DeleteType d =noDestroy )
//MWNode(T* a , DeleteType d )
: parent(0) , child(0) , sibling(0) , Info<T>(a,d) {}
virtual ~MWNode()
{ if( sibling ) delete sibling ;
if( child ) delete child ;
}
friend class MWTree<T> ;
friend ostream& operator<<( ostream& , const MWTree<T>& ) ;
// the declaration above made the compiler issue:
// function templates do not support default arguments
}; // This is the line the compiler indicates with the error
I get this error from the compiler:
function templates do not support default arguments
If I comment out the first constructor and I use the commented one
the problem disappears. This may not seem strange, but I used
default arguments - of course not concerning the dummy T type -
in other similar classes and I had no problems.
I found out that the problem is due to the friend declaration
of the overloaded << operator. Commenting it out and using
the constructor with default arguments works fine, but I had to
introduce new member functions in the class because the operator
can no longer access private data member.
I would like an explanation of this behaviour.
Second problem.
_____________
When I construct a library based on sources containing
templates I always have undefined symbols errors
when I link using the library. If I use directly the objs when
linking the errors disappear. The library is built with
ar rc ...
adding first the objs resulting from compilation and then
the objs in the ./ptrepository directory ( after shortening
their names). I tried compiling with no flags, then with
the -pta flag, the with the -pts flag, but nothing changed.
Can anyone help me ? Thanks!
Stephane
---
______________________________________________________________________________
|
* * | Commission of the European Communities
* * | Joint Research Center
* * |
* * | Institut for Systems Engineering and Informatics
* * |
* * | Socio-Technical Systems Safety Sector
___________________|__________________________________________________________
Dr. Stephane AMARGER Phone : +39 332 785021
Joint Research Center
Commission of the European Communities Fax : +39 332 789472
TP 210
I - 21020 ISPRA (VA) Email : stephane.amarger@cen.jrc.it
ITALY
______________________________________________________________________________