<?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[sized integer types]]></title><description><![CDATA[<p>Hallo zusammen!</p>
<p>Zum Thema 'sized integer types' hab ich grad folgende Passage bei MSDN entdeckt:</p>
<blockquote>
<p>__int8 nSmall; // Declares 8-bit integer<br />
__int16 nMedium; // Declares 16-bit integer<br />
__int32 nLarge; // Declares 32-bit integer<br />
__int64 nHuge; // Declares 64-bit integer</p>
<p>The types __int8, __int16, and __int32 are synonyms for the ANSI types that have the same size, and are useful for writing portable code that behaves identically across multiple platforms. Note that the __int8 data type is synonymous with type char, __int16 is synonymous with type short, and __int32 is synonymous with type int. The __int64 type has no ANSI equivalent.</p>
</blockquote>
<p>Jetzt frag ich mich natuerlich was hinter __int64 steckt?<br />
Koennte man __int64 evtl. mit long long vergleichen?<br />
Ich waer naemlich an einem <strong>plattformunabhaengigen</strong> 64 bit integer interessiert!</p>
<p>Gruesse,<br />
TS++</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/133409/sized-integer-types</link><generator>RSS for Node</generator><lastBuildDate>Thu, 27 Aug 2026 23:25:12 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/133409.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 17 Jan 2006 14:53:00 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to sized integer types on Tue, 17 Jan 2006 14:56:53 GMT]]></title><description><![CDATA[<p>Hallo zusammen!</p>
<p>Zum Thema 'sized integer types' hab ich grad folgende Passage bei MSDN entdeckt:</p>
<blockquote>
<p>__int8 nSmall; // Declares 8-bit integer<br />
__int16 nMedium; // Declares 16-bit integer<br />
__int32 nLarge; // Declares 32-bit integer<br />
__int64 nHuge; // Declares 64-bit integer</p>
<p>The types __int8, __int16, and __int32 are synonyms for the ANSI types that have the same size, and are useful for writing portable code that behaves identically across multiple platforms. Note that the __int8 data type is synonymous with type char, __int16 is synonymous with type short, and __int32 is synonymous with type int. The __int64 type has no ANSI equivalent.</p>
</blockquote>
<p>Jetzt frag ich mich natuerlich was hinter __int64 steckt?<br />
Koennte man __int64 evtl. mit long long vergleichen?<br />
Ich waer naemlich an einem <strong>plattformunabhaengigen</strong> 64 bit integer interessiert!</p>
<p>Gruesse,<br />
TS++</p>
]]></description><link>https://www.c-plusplus.net/forum/post/968986</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/968986</guid><dc:creator><![CDATA[TS++]]></dc:creator><pubDate>Tue, 17 Jan 2006 14:56:53 GMT</pubDate></item><item><title><![CDATA[Reply to sized integer types on Tue, 17 Jan 2006 15:08:50 GMT]]></title><description><![CDATA[<p>ja, und du kannst so etwas in der art machen:</p>
<pre><code class="language-cpp">#if defined(_MSC_VER) &amp;&amp; (_MSC_VER &lt;= 1200) /* wenn MSVC und Version &lt;= 6 */
 typedef unsigned __int64   ULONGLONG;
 typedef __int64            LONGLONG;
#else
 typedef unsigned long long ULONGLONG;
 typedef long long          LONGLONG;
#endif
</code></pre>
<p>siehe auch<br />
<a href="http://www.c-plusplus.net/forum/viewtopic-var-t-is-109531.html" rel="nofollow">http://www.c-plusplus.net/forum/viewtopic-var-t-is-109531.html</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/969006</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/969006</guid><dc:creator><![CDATA[asr]]></dc:creator><pubDate>Tue, 17 Jan 2006 15:08:50 GMT</pubDate></item><item><title><![CDATA[Reply to sized integer types on Tue, 17 Jan 2006 15:27:39 GMT]]></title><description><![CDATA[<p>long long gibts in Standard-C++ nicht, nur in C. Der gcc bietet das als Erweiterung an.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/969032</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/969032</guid><dc:creator><![CDATA[Bashar]]></dc:creator><pubDate>Tue, 17 Jan 2006 15:27:39 GMT</pubDate></item><item><title><![CDATA[Reply to sized integer types on Tue, 17 Jan 2006 15:28:38 GMT]]></title><description><![CDATA[<p>Was ist daran dann plattform-bzw. compilerunabhängig?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/969033</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/969033</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Tue, 17 Jan 2006 15:28:38 GMT</pubDate></item><item><title><![CDATA[Reply to sized integer types on Tue, 17 Jan 2006 15:49:32 GMT]]></title><description><![CDATA[<p>Wenn es wirklich plattformübergreifend werden soll, sollte man sich das Tool <strong>configure</strong> verwenden.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/969057</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/969057</guid><dc:creator><![CDATA[Any]]></dc:creator><pubDate>Tue, 17 Jan 2006 15:49:32 GMT</pubDate></item><item><title><![CDATA[Reply to sized integer types on Tue, 17 Jan 2006 19:56:56 GMT]]></title><description><![CDATA[<p>TS++ schrieb:</p>
<blockquote>
<p>Ich waer naemlich an einem <strong>plattformunabhaengigen</strong> 64 bit integer interessiert!</p>
</blockquote>
<p>Ob du es wirklich vollkommen plattformunabhängig hinbekommst, glaube ich kaum. Mit Sicherheit gibt es Plattformen und entsprechende Compiler, die einfach keinen 64 Bit Typ kennen. Dann kannst du dir nur selbst was basteln. Aber evtl. ist <a href="http://www.c-plusplus.net/forum/viewtopic-var-t-is-131658.html" rel="nofollow">dieser</a> Thread für dich interessant. Du fütterst einfach die Typliste mit allen möglichen zur Verfügung stehenden Typen und bekommst am Ende einen passenden Typen (oder auch nicht) mit entsprechender Bitgrösse und Vorzeichen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/969287</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/969287</guid><dc:creator><![CDATA[groovemaster]]></dc:creator><pubDate>Tue, 17 Jan 2006 19:56:56 GMT</pubDate></item><item><title><![CDATA[Reply to sized integer types on Wed, 18 Jan 2006 09:37:36 GMT]]></title><description><![CDATA[<p>Danke groovemaster fuer den Tipp! <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
<p>Leider kommt schon mal der Borland-Compiler nicht damit zurecht: <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /></p>
<blockquote>
<p>E2489 Maximum option context replay depth exceeded; check for recursion at line 7</p>
</blockquote>
<p>Das betrifft die folgende Zeile:</p>
<pre><code class="language-cpp">static const size_t result = compute_bits_per_byte&lt;(Value &gt;&gt; 1), N + 1&gt;::result;
</code></pre>
<p>Mir ist nochwas aufgefallen ( wahrscheinlich lieg ich aber mal wieder daneben! ):<br />
Der ganze Ansatz basiert doch auf der Idee spezielle Templateimplementierungen durch Fallunterscheidung auszuwaehlen, oder? Implementiert wurde diese Fallunterscheidung mit der Annahme, dass der Compiler Nichtliterale in der Spezifikationsliste des Templates akzeptiert:</p>
<pre><code class="language-cpp">if_then_else&lt; Size == bit_sizeof(typename Element::type), 
              Element, 
              select_type&lt;Size, typename Element::next&gt; 
            &gt;::result tmp;
</code></pre>
<p>Hier steht ja offensichtlich ein &quot;komplexer&quot; boolscher Ausdruck innerhalb der spitzen Klammern. Ich hab bisher immer geglaubt, dass nur Literale zulaessig waeren!!!???<br />
Lieg ich damit nun voellig falsch oder ist das in Deinem Fall nur ein Compilerspezifisches Feature?</p>
<p>Danke!</p>
<p>Gruesse,<br />
TS++</p>
]]></description><link>https://www.c-plusplus.net/forum/post/969520</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/969520</guid><dc:creator><![CDATA[TS++]]></dc:creator><pubDate>Wed, 18 Jan 2006 09:37:36 GMT</pubDate></item><item><title><![CDATA[Reply to sized integer types on Wed, 18 Jan 2006 09:56:18 GMT]]></title><description><![CDATA[<p>OK der zweite Punkt hat sich erledigt!</p>
<p>Es muessen nicht zwangslaeufig Literale sein. Offensichtlich wird ein Aufruf von sizeof(...) als konstanter Ausdruck angesehen und die sind zulaessig.</p>
<p>Nur uebersetzen laesst sich der Code immernoch nicht!!! <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /></p>
<p>Doch nicht die Loesung nach der ich gesucht hab!</p>
<p>Gruesse,<br />
TS++</p>
]]></description><link>https://www.c-plusplus.net/forum/post/969537</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/969537</guid><dc:creator><![CDATA[TS++]]></dc:creator><pubDate>Wed, 18 Jan 2006 09:56:18 GMT</pubDate></item><item><title><![CDATA[Reply to sized integer types on Wed, 18 Jan 2006 10:52:52 GMT]]></title><description><![CDATA[<p>Kann durchaus sein, dass die Unterstützung deines Compilers in Sachen Templates noch nicht so weit ist. Wer intensiven gebrauch von Templates macht muss zwangsweise einen neuen Compiler verwenden.</p>
<p>Hast du mal eine der anderen Lösungen versucht? So wie ich das sehe hat dein Compiler nur eine sehr geringe maximale Rekursionstiefe (vllt. kann man die in den Einstellungen irgendwo hochsetzen, musst du mal schauen). Konstante Ausdrücke kann ein Compiler schon zur Compiletime auswerten, für ein sizeof( Typ ) kann dein Compiler direkt die Größe in Bytes einsetzen und ein Konstante == Konstante kann er ebenfalls bereits zur Compiletime auf true und false auswerten.<br />
Ob er das Komplement schon zur Compiletime auswerten können muss kann ich dir jetzt nicht sagen, aber die vorherigen Lösungsvorschläge berechnen die Anzahl der Bits nicht von Hand sondern verwenden eine Konstante aus climits, also versuch mal eine von denen <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/969604</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/969604</guid><dc:creator><![CDATA[Any]]></dc:creator><pubDate>Wed, 18 Jan 2006 10:52:52 GMT</pubDate></item><item><title><![CDATA[Reply to sized integer types on Wed, 18 Jan 2006 11:46:55 GMT]]></title><description><![CDATA[<p>TS++ schrieb:</p>
<blockquote>
<p>Leider kommt schon mal der Borland-Compiler nicht damit zurecht: <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /></p>
</blockquote>
<p>Kann sein, dass der Borland Compiler für Template Metaprogrammierung nicht besonders geeignet ist. Getestet wurde der Code jedenfalls mit einem aktuellen MSC und GCC.</p>
<p>TS++ schrieb:</p>
<blockquote>
<blockquote>
<p>E2489 Maximum option context replay depth exceeded; check for recursion at line 7</p>
</blockquote>
<p>Das betrifft die folgende Zeile:</p>
<pre><code class="language-cpp">static const size_t result = compute_bits_per_byte&lt;(Value &gt;&gt; 1), N + 1&gt;::result;
</code></pre>
</blockquote>
<p>Die Idee war eigentlich, solche &quot;sized integer&quot; Typen ohne jegliche externe Hilfsmittel zu bekommen. Die Bits pro Byte auszurechnen, ist eigentlich erst als letztes hinzugekommen. Wenn dein Compiler das nicht kann, dann kannst du auch das entsprechende Makro aus der stdlib nehmen.</p>
<pre><code class="language-cpp">// statt
#define bit_sizeof(x) (sizeof(x) * compute_bits_per_byte&lt;~(unsigned char)(0), 0&gt;::result)
// dann halt so
#define bit_sizeof(x) (sizeof(x) * CHAR_BIT) // &lt;climits&gt;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/969640</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/969640</guid><dc:creator><![CDATA[groovemaster]]></dc:creator><pubDate>Wed, 18 Jan 2006 11:46:55 GMT</pubDate></item><item><title><![CDATA[Reply to sized integer types on Thu, 19 Jan 2006 08:27:04 GMT]]></title><description><![CDATA[<p>Danke Dir groovemaster!</p>
<p>Ich werd's mal ausprobieren!</p>
<p>Gruesse,<br />
TS++</p>
]]></description><link>https://www.c-plusplus.net/forum/post/970274</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/970274</guid><dc:creator><![CDATA[TS++]]></dc:creator><pubDate>Thu, 19 Jan 2006 08:27:04 GMT</pubDate></item></channel></rss>