This is the mail archive of the gcc@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]

Regression? HPUX/OS X linker problems (was: Static variables in templates}


Hello,
  The problem with the linker's inability to recognize static variables in 
templates is not confined to HPUX 11. Mac OS X has the same problem too. 
However, it apparently works with gcc 2.95.x; should it be considered a 
regression, then?
  I cannot test gcc 2.95.x with HPUX as it does not seem to build properly. 
Anyway, in hopes that this might help debugging, here's the message from some 
folks porting KDE to Mac OS X:
  http://lists.kde.org/?l=kde-nonlinux&m=102298990730459&w=2
As always, any help is greatly appreciated.

Thanks,
Ravi

----------  Original Message  ----------

Subject: Static variables in templates
Date: Friday 31 May 2002 05:54 pm
From: Ravikiran Rajagopal <ravi@ee.eng.ohio-state.edu>
To: gcc@gcc.gnu.org

Hello,
  I cannot initialize static variables in templates on HPUX 11. The following
code compiles and works as you would expect it to on Linux, but fails with a
linker error in HPUX. The error message follows the program listing. My
compiler version is gcc-3.1 (built from sources) with binutils-2.12 (built
from sources).
--- test.cc ---
// Template definition
template<class T>
class foo
{
  public:
    foo(T v) : var(v) { times++; };
    T var;
    static int times;
};
template<class T>
int foo<T>::times = 0;
// Now we use this template.
int main( int , char ** )
{
  foo<int> a(23);
  return 0;
}
---------------
On HPUX, it fails with the following linker error:
---------------
eehp015:~/misc> gcc -o test test.cc
/usr/ccs/bin/ld: Unsatisfied symbols:
   foo<int>::times   (first referenced in /var/tmp//ccikfnVs.o) (data)
collect2: ld returned 1 exit status
---------------
Any pointers would be greatly appreciated. This construct is very important,
because large parts of KDE 3.x code depend on it. I am trying to port KDE 3.x
to HPUX with gcc 3.1 release. Please cc any replies/follow-ups to me as I am
not subscribed to the list. In case this is the wrong place to ask this
question, I apologize and request you to kindly direct me to the right fora.
Thank you,
Ravi

-------------------------------------------------------


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