public inbox for gcc-prs@sourceware.org help / color / mirror / Atom feed
From: crawford@goingware.com To: gcc-gnats@gcc.gnu.org Subject: c++/3600: g++ 2.95.3 complains about "unsigned long( 25 )" Date: Fri, 06 Jul 2001 21:26:00 -0000 [thread overview] Message-ID: <20010707041903.5264.qmail@sourceware.cygnus.com> (raw) >Number: 3600 >Category: c++ >Synopsis: g++ 2.95.3 complains about "unsigned long( 25 )" >Confidential: no >Severity: non-critical >Priority: medium >Responsible: unassigned >State: open >Class: rejects-legal >Submitter-Id: net >Arrival-Date: Fri Jul 06 21:26:00 PDT 2001 >Closed-Date: >Last-Modified: >Originator: Michael D. Crawford >Release: g++ 2.95.3-5 >Organization: >Environment: 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. >Description: 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. >How-To-Repeat: g++ -c Foo.cpp >Fix: 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 ); >Release-Note: >Audit-Trail: >Unformatted: ----gnatsweb-attachment---- Content-Type: application/x-unknown-content-type-CodeWarrior_cpp; name="Foo.cpp" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="Foo.cpp" dm9pZCBGb28oKTsNCg0Kdm9pZCBGb28oKQ0Kew0KCXVuc2lnbmVkIGxvbmcgdWw7DQoJDQoJdWwg PSB1bnNpZ25lZCBsb25nKCAyNSApOw0KCQ0KCXJldHVybjsNCn0NCg==
next reply other threads:[~2001-07-06 21:26 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2001-07-06 21:26 crawford [this message] 2001-07-07 6:42 lerdsuwa
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20010707041903.5264.qmail@sourceware.cygnus.com \ --to=crawford@goingware.com \ --cc=gcc-gnats@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).