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]

Problem with explicit template instanciation


Hello,

I've got a problem with explicit instanciation and 
"undefined symbol" when linking.

I've got the following source

namespace CDK
{
    struct ExcpManip
    {
        string    m_attr1;
        string    m_attr2;
    };

    template <class KeyType, class ValueType>
        ExcpManip
        Param( const KeyType& , const ValueType& )
        {
            // ... somecode ....
        }
}



I compile all my source with -fno-implicit-templates except the
following code which I compile without -fno-implicit-templates:

namespace CDK
{
    ExcpManip    Param( int const& , int const& );
    ExcpManip    Param( int const& , list<basic_string<char> > 
const & );
    ExcpManip    Param( char* const& , char* const& );
}


I compile all of this into a static library, which I link with
a code using the 3 kind of Param defined above.

I have undefined symbol only for the 3rd one (with char*) !

I use the Param function in the program like this:
excp << Param( "file_name" , "name of file ..." )

I could not achieve my program to link against my library. I
do not understand how to declare template that use char* 
because all other type are found at link time !!!!!!!!!!

All my "undefined symbol" has "char*" as template parameters.
If I do the following:

As shown above, if I write:

list<string> l_lst;
excp << Param( 1 , l_lst );

This is found (because of the declaration of:
ExcpManip    Param( int const& , list<basic_string<char> > 
const & ), I think)

But, if I wrote:

list<string> l_lst;
excp << Param( "1" , l_lst );

and that I define:
ExcpManip    Param( char* const& , list<basic_string<char> > 
const & ); 

The symbol is not found !!!!!


Please could you explain ? And tell me how to explicitly
declare template that use char*, or even tell me what's
wrong ?

Thanks a lot
Laurent Marzullo

Accédez au courrier électronique de La Poste : www.laposte.net ; 
3615 LAPOSTENET (0,13 €/mn) ; tél : 08 92 68 13 50 (0,34€/mn)"




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