bug-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

-frepo g++ bug ?


From: Marat Ruvinov
Subject: -frepo g++ bug ?
Date: Mon, 12 Feb 2001 10:39:37 -0500

Hello,

I wanted to force g++ to "automatically" instantiate template code using
the -frepo option described in the g++ manual.

> g++ -v
gcc version egcs-2.91.66

> g++ -frepo -c main.cc
> g++ -frepo -c templates.cc
> g++ main.o templates.o -o  main

main.o: In function 'main':
main.o (.text+0xb): undefined reference to 'A<int>::f(void)'
collect2: ld returned 1 exit status

// templates.h
//////////////////////////////////////////////////
template <class T>
class A {
public:
    void foo();    // declare foo()
};

// templates.cc
////////////////////////////////////////////////////
#include "templates.h"

template <class T>
void A<T>::foo() {}   // define foo()


// main.cc
//////////////////////////////////////////////////////
#include "templates.h"

main()
{
   A<int> obj;  // use the template
   obj.foo();  // A<int> not instantiated implicitly !!!!!!
}

Is this a bug? Or am a I doing something wrong?

Marat

--



reply via email to

[Prev in Thread] Current Thread [Next in Thread]