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

RE: Template Member Function Compilation Error on Solaris


Wei,

Yes, this makes sense.  By definition, all identifiers starting with an
underscore or containing two consecutive underscores are reserved for
the compiler.  You should avoid using such identifiers.

Thanks,
Lyle


-----Original Message-----
From: gcc-help-owner@gcc.gnu.org [mailto:gcc-help-owner@gcc.gnu.org] On
Behalf Of Wei Qin
Sent: Wednesday, February 02, 2005 9:02 AM
To: gcc-help@gcc.gnu.org
Subject: Re: Template Member Function Compilation Error on Solaris

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
>



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