help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Is this a parser bug?


From: Maurizio Loreti
Subject: Re: Is this a parser bug?
Date: 14 Oct 2004 11:08:18 +0200
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3

"Marcel Loose" <loose@astron.nl> writes:
> #include <sys/types.h>  // contains typedef for ulong
> namespace N
> {
>   typedef unsigned long ulong;
> }
> using namespace N;
> int main()
> {
>   N::ulong nu; // OK.
>   ulong u;     // Parse error. Huh?
> }

You have in scope two definitions of ulong.  Remove the "using
namespace N;" line and all will be OK: nu will use the N::ulong
definition, and u the sys/types.h definition.

MLO@mlinux 33 $ cat foo.cxx
#include <sys/types.h>
namespace N {
  typedef unsigned long ulong;
}
int main()
{
  N::ulong nu;
  ulong u;
}
MLO@mlinux 34 $ g++ -std=c++98 -pedantic -W -Wall -o foo foo.cxx
foo.cxx: In function `int main()':
foo.cxx:7: warning: unused variable 'nu'
foo.cxx:8: warning: unused variable 'u'
MLO@mlinux 35 $

-- 
Maurizio Loreti                         http://www.pd.infn.it/~loreti/mlo.html
Dept. of Physics, Univ. of Padova, Italy              ROT13: ybergv@cq.vasa.vg


reply via email to

[Prev in Thread] Current Thread [Next in Thread]