Template Member Function Compilation Error on Solaris

Wei Qin weiqin@gmail.com
Wed Feb 2 16:02:00 GMT 2005


Never mind. I identified the problem. Solaris defines _L, _S, etc.
macros in some libc header files.  So the _L, _S in my code was
replaced with some constants after preprocessing. This is a legacy
problem with Solaris library, not the code.
Same problem exists for ports of cygwin, and possibly OS X.


On Wed, 2 Feb 2005 02:48:12 -0500, Wei Qin <weiqin@gmail.com> wrote:
> I have some compilation error for one template member function on
> solaris g++ 3.3.2. I don't have a problem on x86/linux port of g++.
> 
> #include "mpz_base.hpp" // defines _mpz_base_
> template <unsigned _Len_, bool _Sign_> class _mpint_t_ {
> 
>         public:
>                 _mpint_t_() : m() {}
>                 _mpint_t_(const _mpz_base_<_Len_,_Sign_>& v) : m(v) {}
> 
>                 ~_mpint_t_() {}
> 
>                 const _mpz_base_<_Len_,_Sign_> val() const {return m;}
> 
>                // problem here
>                 template <unsigned _L, bool _S> //line 40
>                 void deposit(unsigned lmb, unsigned rmb, const
> _mpz_base_<_L,_S> & x) {
>                         m.set_slice(x, lmb-rmb+1, rmb);
>                 }
> 
>                // line 45
>         ......
> };
> 
> When compiling, g++ complains
> "mpint_type.hpp:40: error: parse error before numeric constant"
> "mpint_type.hpp:45: error: semicolon missing after declaration of `
>    _mpint_t_<_Len_, _Sign_>'
> 
> I am been struggling with this problem for a while. Is this a problem
> of the compiler or my coding? Experts please advise. Thanks in
> advance.
> 
> Wei
>



More information about the Gcc-help mailing list