This is the mail archive of the
mailing list for the GCC project.
c++/3600: g++ 2.95.3 complains about "unsigned long( 25 )"
- To: gcc-gnats at gcc dot gnu dot org
- Subject: c++/3600: g++ 2.95.3 complains about "unsigned long( 25 )"
- From: crawford at goingware dot com
- Date: 7 Jul 2001 04:19:03 -0000
- Reply-To: crawford at goingware dot com
>Synopsis: g++ 2.95.3 complains about "unsigned long( 25 )"
>Arrival-Date: Fri Jul 06 21:26:00 PDT 2001
>Originator: Michael D. Crawford
>Release: g++ 2.95.3-5
CygWin on Windows NT Service Pack 6, Pentium III machine.
The gcc I have is from the latest CygWin as of a couple weeks
ago. When 3.0 is available for CygWin I'll try that out too. I
think a slackware package for 3.0 is available for my linux systems, so I'll
try that out sometime soon too. I'm not up to building gcc right now.
The code in file Foo.cpp calls unsigned long's conversion
operator to cast an int to an unsigned long. g++ complains:
Foo.cpp:7: parse error before "long"
The code in question compiles (and works) without complaint with Microsoft
Visual C++ version 6 service pack 5, as well is Metrowerks CodeWarrior
version 6.1 for Windows.
g++ -c Foo.cpp
surround the unsigned long with parenthesis, so the "unsigned"
is grouped with "long" to make "unsigned long" a unit:
ul = (unsigned long)( 25 );
I'm not clear whether that continues to be unsigned longs
one-parameter constructor conversion operator or just an
old-fashioned c-style cast.
An alternative is to use a typedef that is (as typedef's must be)
a single token. My application is written for the Win32 api, and in
Win32, there is a "typedef unsigned long ULONG;"
ul = ULONG( 25 );
it also works to use a c++ style static cast:
ul = static_cast< unsigned long >( 25 );
Content-Type: application/x-unknown-content-type-CodeWarrior_cpp; name="Foo.cpp"
Content-Disposition: attachment; filename="Foo.cpp"