<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Warnung entfernen]]></title><description><![CDATA[<p>Folgender Code:</p>
<pre><code>file&lt;&lt;static_cast&lt;bool&gt;(byte &amp; (1&lt;&lt;i));
</code></pre>
<p>Ich pruefe also welche der 8 Bits gesetzt sind und will dementsprechend &quot;0&quot; oder &quot;1&quot; in die Datei schreiben. Byte ist std::uint8_t. Funktioniert auch, allerdings mit Warnung:</p>
<blockquote>
<p>warning C4800: 'int': Variable wird auf booleschen Wert ('True' oder 'False') gesetzt</p>
</blockquote>
<p>Scheinbar hilft der Cast gar nichts</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/320606/warnung-entfernen</link><generator>RSS for Node</generator><lastBuildDate>Thu, 23 Jul 2026 18:38:10 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/320606.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 04 Oct 2013 19:04:58 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Warnung entfernen on Fri, 04 Oct 2013 19:04:58 GMT]]></title><description><![CDATA[<p>Folgender Code:</p>
<pre><code>file&lt;&lt;static_cast&lt;bool&gt;(byte &amp; (1&lt;&lt;i));
</code></pre>
<p>Ich pruefe also welche der 8 Bits gesetzt sind und will dementsprechend &quot;0&quot; oder &quot;1&quot; in die Datei schreiben. Byte ist std::uint8_t. Funktioniert auch, allerdings mit Warnung:</p>
<blockquote>
<p>warning C4800: 'int': Variable wird auf booleschen Wert ('True' oder 'False') gesetzt</p>
</blockquote>
<p>Scheinbar hilft der Cast gar nichts</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2357929</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2357929</guid><dc:creator><![CDATA[Wwwwarnung]]></dc:creator><pubDate>Fri, 04 Oct 2013 19:04:58 GMT</pubDate></item><item><title><![CDATA[Reply to Warnung entfernen on Fri, 04 Oct 2013 19:09:01 GMT]]></title><description><![CDATA[<p>Das sollte eigentlich keine Warnung produzieren, denn das ist keine Pitfall.<br />
Ignorieren.</p>
<p>P.S.: Du willst also das Byte binär in den Stream schieben? Falls du C++11 zur Verfügung hast, nutze bitset.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2357930</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2357930</guid><dc:creator><![CDATA[Columbo]]></dc:creator><pubDate>Fri, 04 Oct 2013 19:09:01 GMT</pubDate></item><item><title><![CDATA[Reply to Warnung entfernen on Fri, 04 Oct 2013 19:18:07 GMT]]></title><description><![CDATA[<p>Wwwwarnung schrieb:</p>
<blockquote>
<p>Scheinbar hilft der Cast gar nichts</p>
</blockquote>
<p>Nee, hilft bei MSVC nicht. Deswegen benutze ich da den not-not-Trick.</p>
<pre><code>file&lt;&lt;!!(byte &amp; (1&lt;&lt;i));
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2357931</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2357931</guid><dc:creator><![CDATA[volkard]]></dc:creator><pubDate>Fri, 04 Oct 2013 19:18:07 GMT</pubDate></item><item><title><![CDATA[Reply to Warnung entfernen on Fri, 04 Oct 2013 19:21:40 GMT]]></title><description><![CDATA[<p>oder vernünftig:</p>
<pre><code>(byte &amp; (1&lt;&lt;i)) != 0
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2357932</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2357932</guid><dc:creator><![CDATA[boolean]]></dc:creator><pubDate>Fri, 04 Oct 2013 19:21:40 GMT</pubDate></item><item><title><![CDATA[Reply to Warnung entfernen on Fri, 04 Oct 2013 19:22:41 GMT]]></title><description><![CDATA[<p>Ach, hier geht es darum, die Warnung mit Tricks zu entfernen?</p>
<blockquote>
<p>Deswegen benutze ich da den not-not-Trick.</p>
</blockquote>
<p>Schon merkwürdig, das VC++ es hier sieht, da aber nicht.</p>
<p>Sieht es das bei einem function-style-cast?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2357933</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2357933</guid><dc:creator><![CDATA[Columbo]]></dc:creator><pubDate>Fri, 04 Oct 2013 19:22:41 GMT</pubDate></item><item><title><![CDATA[Reply to Warnung entfernen on Fri, 04 Oct 2013 23:44:58 GMT]]></title><description><![CDATA[<p>Lieber Stern, lies bitte den MSDN Eintrag zu dieser Warning, da steht genau beschrieben worum es geht.<br />
Dann musst du dich auch weniger wundern.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2357979</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2357979</guid><dc:creator><![CDATA[hustbaer]]></dc:creator><pubDate>Fri, 04 Oct 2013 23:44:58 GMT</pubDate></item><item><title><![CDATA[Reply to Warnung entfernen on Sat, 05 Oct 2013 00:03:01 GMT]]></title><description><![CDATA[<p>hustbaer schrieb:</p>
<blockquote>
<p>Lieber Stern, lies bitte den MSDN Eintrag zu dieser Warning, da steht genau beschrieben worum es geht.</p>
</blockquote>
<p>Das habe ich :).</p>
<blockquote>
<p>This warning is generated when a value that is not bool is assigned or coerced into type bool.</p>
</blockquote>
<p>Volkards Variante sollte demnach also eine Warnung produzieren.<br />
Daher wundere ich mich.</p>
<p>Meine Frage zum function style cast ist damit aber geklärt:</p>
<blockquote>
<p>Casting the expression to type bool will not disable the warning, which is by design.</p>
</blockquote>
<p>Alle Casts haben sie also speziell behandelt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2357986</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2357986</guid><dc:creator><![CDATA[Columbo]]></dc:creator><pubDate>Sat, 05 Oct 2013 00:03:01 GMT</pubDate></item><item><title><![CDATA[Reply to Warnung entfernen on Sat, 05 Oct 2013 01:22:41 GMT]]></title><description><![CDATA[<ul>
<li>schrieb:</li>
</ul>
<blockquote>
<p>hustbaer schrieb:</p>
<blockquote>
<p>Lieber Stern, lies bitte den MSDN Eintrag zu dieser Warning, da steht genau beschrieben worum es geht.</p>
</blockquote>
<p>Das habe ich :).</p>
</blockquote>
<p>Ja, jetzt. Davor offensichtlich nicht.</p>
<blockquote>
<blockquote>
<p>This warning is generated when a value that is not bool is assigned or coerced into type bool.</p>
</blockquote>
<p>Volkards Variante sollte demnach also eine Warnung produzieren.<br />
Daher wundere ich mich.</p>
</blockquote>
<p>Wenn du <em>coerced into type bool</em> unbedingt so verstehen willst dass es auch <code>!int_value</code> mit einschliesst, dann ja.<br />
Was aber spätestens mit</p>
<blockquote>
<p>'type' : forcing value to bool 'true' or 'false' <strong>(performance warning)</strong></p>
</blockquote>
<p>klar sein sollte: bei der Warning geht's nicht darum dass der Compiler Angst hat dass man was falsch macht. Sie soll ein Tip sein, dass man was macht, was u.U. nicht unbedingt schnell ist.<br />
Das war nämlich zu Zeiten wo die meisten CPUs <code>CMOV</code> noch nicht unterstützt haben und schlechte Branch-Prediction hatten, aber bereits sehr tiefe Pipelines, relativ teuer.</p>
<p>Und dass es mächtig nervt, wenn ein Tip, wie man was besser machen könnte, an vielen Stellen kommt, wo man etwas für C(++) ganz normales macht, nämlich <code>if (int_value)</code> bzw. <code>if (!int_value)</code> zu schreiben, sollte klar sein.<br />
Davon abgesehen wäre sie dort auch nicht wirklich angebracht, denn ein <code>if (int_value)</code> oder <code>if (!int_value)</code> ist genau so schnell oder langsam wie ein <code>if (bool_value)</code> . Den bedingten Sprung kann man bei <code>if</code> ja schwer einsparen. Ausser eben manchmal über <code>CMOV</code> .</p>
<p>Einzig bei einer Zuweisung mit <code>!int_value</code> (oder eben <code>!!int_value</code> ) wäre diese <em>performance warning</em> noch angebracht. Denn das hätten auch damals Compiler schon ohne <code>CMOV</code> mit <code>bool</code> schneller machen können als mit <code>int</code> . Andrerseits war es damals auch noch nicht so &quot;in&quot; standardkonformen Code zu schreiben. Und da ein über <code>XOR reg, 1</code> implementiertes <code>!</code> bei nicht standardkonformem Code zu einigen Problemen führen kann, würde mich fast wundern, wenn MSVC das so gemacht hätte.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2357993</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2357993</guid><dc:creator><![CDATA[hustbaer]]></dc:creator><pubDate>Sat, 05 Oct 2013 01:22:41 GMT</pubDate></item><item><title><![CDATA[Reply to Warnung entfernen on Sat, 05 Oct 2013 06:03:06 GMT]]></title><description><![CDATA[<p>hustbaer schrieb:</p>
<blockquote>
<p>…</p>
</blockquote>
<p>Das könnte der Grund sein, warum !!c geht. Der bool-cast im !c warnt vielleicht (by design) deswegen nicht, weil er eh fast nur in if(!c) vorkommt (billig) und recht selten in Zuweisungen..</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2357996</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2357996</guid><dc:creator><![CDATA[volkard]]></dc:creator><pubDate>Sat, 05 Oct 2013 06:03:06 GMT</pubDate></item></channel></rss>