|
Boost : |
From: Simon Atanasyan (atanasyan_at_[hidden])
Date: 2007-09-29 01:50:20
% cat test.cc
static int bar(int)
{
return 0;
}
template <typename T>
int foo(T arg)
{
return bar(arg);
}
int main()
{
return foo(1);
}
% CC -V test.cc
CC: Sun C++ 5.9 SunOS_sparc Patch 124863-01 2007/07/25
ccfe: Sun C++ 5.9 SunOS_sparc Patch 124863-01 2007/07/25
"test.cc", line 9: Error: Reference to static bar(int) not allowed in
template foo<int>(int), try using -features=tmplrefstatic.
"test.cc", line 14: Where: While instantiating "foo<int>(int)".
"test.cc", line 14: Where: Instantiated from non-template code.
1 Error(s) detected.
2007/9/29, Sid Sacek <ssacek_at_[hidden]>:
>
> Hi,
>
> Thanks for that answer, but I still don't think I understand. This sample
> test code builds with and without the -features=tmplrefstatic argument, so I
> guess I need a code example to clarify it, if you don't mind.
>
> Thank you,
> -Sid Sacek
>
> template< typename Ty > struct XYZ
> {
> static int si;
> static void foo( void );
> XYZ( void ) { si = 555; foo(); }
> };
>
> int XYZ< int >::si = 333;
> template<> void XYZ< int >::foo( void ) { return; }
>
> int main( void )
> {
> XYZ< int > xyz;
> }
>
> -----Original Message-----
> From: boost-bounces_at_[hidden] [mailto:boost-bounces_at_[hidden]]
> On Behalf Of Simon Atanasyan
> Sent: Friday, September 28, 2007 1:24 PM
> To: boost_at_[hidden]
> Subject: Re: [boost] SUN Compiler option -features=tmplrefstatic
>
> The short answer is very simple. By default Sun C++ compiler does not
> allow to refer static symbols from templates. -features=tmplrefstatic
> turns on this ability.
>
> 2007/9/28, Sid Sacek <ssacek_at_[hidden]>:
> >
> > To whom it may concern,
> >
> > When compiling Boost code using the Sun compiler, the Boost documentation
> > makes this statement.
> >
> > Quote:
> > When using this compiler on complex C++ code, such as the Boost C++
> library,
> > it is recommended to specify the following options when intializing the
> sun
> > module:
> > -library=stlport4 -features=tmplife -features=tmplrefstatic
> > End-Quote:
> >
> >
> > I don't understand the effect of the 'tmplrefstatic' argument on the
> > compiled code. Why is that option recommended, ie. What does it do?
> >
> > I searched the web for a couple of hours for an explanation and couldn't
> > find an answer to my question. I'm hoping somebody on this list knows
> > because Boost is recommending it.
> >
> > Thanks in advance,
> > -Sid Sacek
>
> --
> Simon Atanasyan
> _______________________________________________
> Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost
>
>
> _______________________________________________
> Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
>
-- Simon Atanasyan
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk