Re: VC 2005 Warning C4244
"Jesus de Santos Garcia" <[email protected]> Thu, 13 Dec 2007 01:01:26 +0100
| Newsgroups | gmane.games.devel.windows |
|---|---|
| Message-ID | <[email protected]> |
--===============1688556953== Content-Type: multipart/alternative; boundary="----=_Part_3280_15825497.1197504086084" ------=_Part_3280_15825497.1197504086084 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline Hmm... I am not having warnings in code like that with Visual Studio 2005 SP1 and W4... strange, isn't it? On Dec 12, 2007 12:56 PM, Dan Glastonbury <[email protected]> wrote: > G'Day, > I'm trying to compile at warning level 4 and I'm getting a lot of > spurious C4244. This warning is about an integer narrow storing > possibly loosing information. > > The problem is with this kind of code: > > u_short n = htons(x); > > htons returns a u_short but, as the standard says, the result of > integer expressions is promoted to int (or unsigned) and is causing > the warning. Is there anyway I can code it to shut up VC 2005? > > u_short n = (u_short)htons(x) doesn't work, because the result is > still promoted in the context of an expression! > > cheers > DanG > > -- > Dan Glastonbury, Dan dot Glastonbury at gmail dot com > `Pour encourjay lays ortras' > > ------------------------------------------------------------------------- > SF.Net email is sponsored by: > Check out the new SourceForge.net Marketplace. > It's the best place to buy or sell services for > just about anything Open Source. > http://sourceforge.net/services/buy/index.php > _______________________________________________ > Gamedevlists-windows mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/gamedevlists-windows > Archives: > http://sourceforge.net/mailarchive/forum.php?forum_id=555 > ------=_Part_3280_15825497.1197504086084 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline Hmm...<br><br>I am not having warnings in code like that with Visual Studio 2005 SP1 and W4...<br><br>strange, isn't it?<br><br><div class="gmail_quote">On Dec 12, 2007 12:56 PM, Dan Glastonbury <<a href="mailto:[email protected]"> [email protected]</a>> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">G'Day,<br> I'm trying to compile at warning level 4 and I'm getting a lot of <br>spurious C4244. This warning is about an integer narrow storing<br>possibly loosing information.<br><br>The problem is with this kind of code:<br><br>u_short n = htons(x);<br><br>htons returns a u_short but, as the standard says, the result of <br>integer expressions is promoted to int (or unsigned) and is causing<br>the warning. Is there anyway I can code it to shut up VC 2005?<br><br>u_short n = (u_short)htons(x) doesn't work, because the result is<br>still promoted in the context of an expression! <br><br>cheers<br>DanG<br><br>--<br>Dan Glastonbury, Dan dot Glastonbury at gmail dot com<br>`Pour encourjay lays ortras'<br><br>-------------------------------------------------------------------------<br>SF.Net email is sponsored by: <br>Check out the new SourceForge.net Marketplace.<br>It's the best place to buy or sell services for<br>just about anything Open Source.<br><a href="http://sourceforge.net/services/buy/index.php" target="_blank">http://sourceforge.net/services/buy/index.php </a><br>_______________________________________________<br>Gamedevlists-windows mailing list<br><a href="mailto:[email protected]">[email protected]</a><br><a href="https://lists.sourceforge.net/lists/listinfo/gamedevlists-windows" target="_blank"> https://lists.sourceforge.net/lists/listinfo/gamedevlists-windows</a><br>Archives:<br><a href="http://sourceforge.net/mailarchive/forum.php?forum_id=555" target="_blank">http://sourceforge.net/mailarchive/forum.php?forum_id=555 </a><br></blockquote></div><br> ------=_Part_3280_15825497.1197504086084-- --===============1688556953== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline ------------------------------------------------------------------------- SF.Net email is sponsored by: Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace --===============1688556953== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Gamedevlists-windows mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/gamedevlists-windows Archives: http://sourceforge.net/mailarchive/forum.php?forum_id=555 --===============1688556953==--