Usenet comp.unix.tru64 (2000-2013)
 help / color / mirror / Atom feed
* CXX compiler problem
@ 2001-11-01 10:20 Tobias Ernst
  2001-11-01 13:47 ` Andreas Unterkircher
  0 siblings, 1 reply; 3+ messages in thread
From: Tobias Ernst @ 2001-11-01 10:20 UTC (permalink / raw)


Hallo All!

I have a problem with the template instantiation code in CXX on this 
platform:

tobi@caracal(524):~/appt/pore> uname -a; cxx -V; cc -V
OSF1 caracal.ica1.uni-stuttgart.de V5.0 910 alpha
Compaq C++ V6.3-014 for Digital UNIX V5.0 (Rev. 910)
Compiler Driver V6.3-014 (cxx) cxx Driver
Compaq C V6.4-214 (dtk) on Digital UNIX V5.0 (Rev. 910)
Compiler Driver V6.4-014 (dtk) cc Driver

The error I get when linking my application is this:

Unresolved:
GrayHist<PTC_ParaIArray<3, signed char>, 3>::porosity(void)
GrayHist<PTC_ParaIArray<3, signed char>, 3>::alt_specsurf(void)

Now the problem is that the class PTC_ParaIArray is defined as

template <class T, int NDIM>
class PTC_ParaIArray:public PTC_ParaIArray_Base<T,NDIM>
{...};

So you see that the type parameter T must be first and the integer 
parameter NDIM must be last. The file that provides alt_specsurf and 
porosity contains the correct symbols (verified with nm):

GrayHist<PTC_ParaIArray<signed char, 3>, 3>::alt_specsurf(void) 
GrayHist<PTC_ParaIArray<signed char, 3>, 3>::porosity(void)

However, for some mysterious reason, the object file where I call these 
functions mysteriously contains requests for 

GrayHist<PTC_ParaIArray<3, signed char>, 3>::alt_specsurf(void)
GrayHist<PTC_ParaIArray<3, signed char>, 3>::porosity(void)

i.E. the integer parameter 3 before the type parameter signed char.

The cxx files that produce those two object files include the SAME .h 
file with the definitions of PTC_ParaIArray. So why on earth does cxx 
resort the template parameters in the one object file, but not in the 
other !?

The code compiles flawlessly with gcc 2.95.2 and with KAI KCC. The code 
does not work with Compaq CXX 6.3-014 and CXX 6.3-012.

If anybody is interested, I can compile a more formal testcase.

Viele Gr��e,
Tobias



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: CXX compiler problem
  2001-11-01 10:20 CXX compiler problem Tobias Ernst
@ 2001-11-01 13:47 ` Andreas Unterkircher
  2001-11-02 13:45   ` Kenneth Block
  0 siblings, 1 reply; 3+ messages in thread
From: Andreas Unterkircher @ 2001-11-01 13:47 UTC (permalink / raw)
  To: Tobias Ernst


I'm not sure whether this is the source of your problem but I remember
that I once also had problems with cxx's template instantiaton. I wanted
to link a library to my C++ program and I also got messages similar to
your messages. The problem was that the library and the program did not
use the same cxx_repository directory. Are you sure that you always use
the same cxx_repository ? You can control it with the -ptr flag.

HTH,
Andreas

> I have a problem with the template instantiation code in CXX on this
> platform:
>
> tobi@caracal(524):~/appt/pore> uname -a; cxx -V; cc -V
> OSF1 caracal.ica1.uni-stuttgart.de V5.0 910 alpha
> Compaq C++ V6.3-014 for Digital UNIX V5.0 (Rev. 910)
> Compiler Driver V6.3-014 (cxx) cxx Driver
> Compaq C V6.4-214 (dtk) on Digital UNIX V5.0 (Rev. 910)
> Compiler Driver V6.4-014 (dtk) cc Driver
>
> The error I get when linking my application is this:
>
> Unresolved:
> GrayHist<PTC_ParaIArray<3, signed char>, 3>::porosity(void)
> GrayHist<PTC_ParaIArray<3, signed char>, 3>::alt_specsurf(void)
>
> Now the problem is that the class PTC_ParaIArray is defined as
>
> template <class T, int NDIM>
> class PTC_ParaIArray:public PTC_ParaIArray_Base<T,NDIM>
> {...};
>
> So you see that the type parameter T must be first and the integer
> parameter NDIM must be last. The file that provides alt_specsurf and
> porosity contains the correct symbols (verified with nm):
>
> GrayHist<PTC_ParaIArray<signed char, 3>, 3>::alt_specsurf(void)
> GrayHist<PTC_ParaIArray<signed char, 3>, 3>::porosity(void)
>
> However, for some mysterious reason, the object file where I call these
> functions mysteriously contains requests for
>
> GrayHist<PTC_ParaIArray<3, signed char>, 3>::alt_specsurf(void)
> GrayHist<PTC_ParaIArray<3, signed char>, 3>::porosity(void)
>
> i.E. the integer parameter 3 before the type parameter signed char.
>
> The cxx files that produce those two object files include the SAME .h
> file with the definitions of PTC_ParaIArray. So why on earth does cxx
> resort the template parameters in the one object file, but not in the
> other !?
[..]



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: CXX compiler problem
  2001-11-01 13:47 ` Andreas Unterkircher
@ 2001-11-02 13:45   ` Kenneth Block
  0 siblings, 0 replies; 3+ messages in thread
From: Kenneth Block @ 2001-11-02 13:45 UTC (permalink / raw)


"Andreas Unterkircher" <unterkir@ivp.bepr.ethz.ch> wrote in message
news:Pine.SGI.4.40.0111011441110.7631-100000@trane.ethz.ch...
>
> I'm not sure whether this is the source of your problem but I remember
> that I once also had problems with cxx's template instantiaton. I wanted
> to link a library to my C++ program and I also got messages similar to
> your messages. The problem was that the library and the program did not
> use the same cxx_repository directory. Are you sure that you always use
> the same cxx_repository ? You can control it with the -ptr flag.
>
> HTH,
> Andreas

Or you can just link you templates staticly into every module that uses
them. This is what GCC does. There are two problems with doing this. 1) This
can cause you executable to become large. 2) Static data that should have
only a single copy will be duplicated.

If gcc is your compiler of choice, you can do "-std gnu" to get Compaq C++
to act more like it. If you prefer a more ANSI/ISO compliant compiler, but
want templates compiled staticly, you can do "-tlocal".





^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2001-11-02 13:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-11-01 10:20 CXX compiler problem Tobias Ernst
2001-11-01 13:47 ` Andreas Unterkircher
2001-11-02 13:45   ` Kenneth Block

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox