<?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[Wozu braucht man solche Typedefs?]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich bin Anfänger und habe einen Quellcodeteil vor mir, womit ich überhaupt nichts anfangen kann. Vielleicht kann mir jemand deuten was es auf sich hat:</p>
<pre><code class="language-cpp">typedef bool          Tbool;
typedef char          Tint8;  // 1 Byte
typedef unsigned char Tuint8;
typedef long          Tint32;
typedef long long     Tint64;
typedef float         Tfloat;
typedef double        Tdouble;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/274366/wozu-braucht-man-solche-typedefs</link><generator>RSS for Node</generator><lastBuildDate>Thu, 27 Aug 2026 16:06:01 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/274366.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 24 Sep 2010 18:29:34 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Wozu braucht man solche Typedefs? on Fri, 24 Sep 2010 18:29:34 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich bin Anfänger und habe einen Quellcodeteil vor mir, womit ich überhaupt nichts anfangen kann. Vielleicht kann mir jemand deuten was es auf sich hat:</p>
<pre><code class="language-cpp">typedef bool          Tbool;
typedef char          Tint8;  // 1 Byte
typedef unsigned char Tuint8;
typedef long          Tint32;
typedef long long     Tint64;
typedef float         Tfloat;
typedef double        Tdouble;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1957027</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1957027</guid><dc:creator><![CDATA[anfänger01]]></dc:creator><pubDate>Fri, 24 Sep 2010 18:29:34 GMT</pubDate></item><item><title><![CDATA[Reply to Wozu braucht man solche Typedefs? on Fri, 24 Sep 2010 18:38:06 GMT]]></title><description><![CDATA[<p>Du machst die dir am Anfang und kannst sie dann konsistent im Programm benutzen. Wenn du statt float dann lieber double hättest, änderst du einfach die typedef einmalig am Anfang statt dir alles Vorkommen im Quelltext suchen zu müssen ... zum Beispiel (hab ich noch nie benötigt, wäre aber eine Mögliche Begründung). Ansonsten hauen die Bezeichner schon nicht hin wenn du auf 64bit kompilierst da einige der Sachen dann eben nicht mehr von der Biotzahl her stimmen...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1957030</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1957030</guid><dc:creator><![CDATA[padreigh]]></dc:creator><pubDate>Fri, 24 Sep 2010 18:38:06 GMT</pubDate></item><item><title><![CDATA[Reply to Wozu braucht man solche Typedefs? on Fri, 24 Sep 2010 18:40:15 GMT]]></title><description><![CDATA[<p>Also ich brauche typedefs hin und wieder um lange Typennamen abzukürzen.</p>
<p>Für solche langen Typen zum Beispiel (ist jetzt nicht das perfekte Beispiel):</p>
<pre><code class="language-cpp">typedef boost::shared_ptr&lt;MyClass&gt;   myClass;
</code></pre>
<p>Was das oben soll weiss ich nicht genau. Woher hast du den diesen Quellcode?</p>
<p>Mein Tipp:<br />
Sehr sparsam mit typedefs umgehen... die können aus meiner Sicht den Code sehr mühsam zum lesen machen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1957031</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1957031</guid><dc:creator><![CDATA[icarus2]]></dc:creator><pubDate>Fri, 24 Sep 2010 18:40:15 GMT</pubDate></item><item><title><![CDATA[Reply to Wozu braucht man solche Typedefs? on Fri, 24 Sep 2010 18:42:18 GMT]]></title><description><![CDATA[<p>padreigh schrieb:</p>
<blockquote>
<p>Ansonsten hauen die Bezeichner schon nicht hin wenn du auf 64bit kompilierst da einige der Sachen dann eben nicht mehr von der Biotzahl her stimmen...</p>
</blockquote>
<p>Ist denn nicht ein long mindestens 32bit groß?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1957032</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1957032</guid><dc:creator><![CDATA[blue-tec]]></dc:creator><pubDate>Fri, 24 Sep 2010 18:42:18 GMT</pubDate></item><item><title><![CDATA[Reply to Wozu braucht man solche Typedefs? on Fri, 24 Sep 2010 20:07:18 GMT]]></title><description><![CDATA[<p>anfänger01 schrieb:</p>
<blockquote>
<p>ich bin Anfänger und habe einen Quellcodeteil vor mir, womit ich überhaupt nichts anfangen kann. Vielleicht kann mir jemand deuten was es auf sich hat:</p>
<pre><code class="language-cpp">typedef bool          Tbool;
typedef char          Tint8;  // 1 Byte
typedef unsigned char Tuint8;
typedef long          Tint32;
typedef long long     Tint64;
typedef float         Tfloat;
typedef double        Tdouble;
</code></pre>
</blockquote>
<p>In diesem speziellen Fall halte ich die Typedefs eher für sinnfrei. Besonders <code>typedef char Tint8;</code> . Ich vermisse da ein <code>signed</code> vor <code>char</code> . Es gibt nämlich 3 Character-Typen, char, signed char und unsigned char, wobei char entweder vorzeichenbehaftet oder vorzeichenlos ist. Das Rechnen mit char sollte man daher vermeiden.</p>
<p>Und sonst kann man sich das Leben mit typedefs leichter machen:</p>
<pre><code class="language-cpp">int main() {
  typedef std::map&lt;std::string,std::string&gt; stringmap;
  stringmap sm;
  sm[&quot;greeting&quot;] = &quot;hello, anfaenger01!&quot;;
  stringmap::iterator it = sm.begin();
  cout &lt;&lt; it-&gt;second &lt;&lt; '\n';
}
</code></pre>
<p>Statt std::map<a href="std::string,std::string" rel="nofollow">std::string,std::string</a> kann nach dem typedef stringmap als Typ verwendet werden. Das kommt auf's gleiche raus...</p>
<p>kk</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1957035</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1957035</guid><dc:creator><![CDATA[krümelkacker]]></dc:creator><pubDate>Fri, 24 Sep 2010 20:07:18 GMT</pubDate></item><item><title><![CDATA[Reply to Wozu braucht man solche Typedefs? on Fri, 24 Sep 2010 18:54:48 GMT]]></title><description><![CDATA[<p>blue-tec schrieb:</p>
<blockquote>
<p>Ist denn nicht ein long mindestens 32bit groß?</p>
</blockquote>
<p>Ja schon, aber:</p>
<p>sizeof(type) liefert bei mir (linux64bit)</p>
<pre><code>bool           1 
char           1 
unsigned char  1 
long           8 
long long      8 
float          4 
double         8
</code></pre>
<pre><code>typedef long          Tint32;
typedef long long     Tint64;
</code></pre>
<p>..also suggerieren die Bezeichner zT weniger als sie dann sind ...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1957036</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1957036</guid><dc:creator><![CDATA[padreigh]]></dc:creator><pubDate>Fri, 24 Sep 2010 18:54:48 GMT</pubDate></item><item><title><![CDATA[Reply to Wozu braucht man solche Typedefs? on Fri, 24 Sep 2010 19:00:00 GMT]]></title><description><![CDATA[<p>icarus2 schrieb:</p>
<blockquote>
<p>Was das oben soll weiss ich nicht genau. Woher hast du den diesen Quellcode?</p>
</blockquote>
<p>Ist ein Programm dessen Code nicht öffentlich gestellt ist.<br />
Könnte es sein, dass man damit je nach Zielsystem 32/64bit die Größen anpasst um die Grenzen konstant zu halten?</p>
<p>Muss ich so etwas machen wenn ich Plattform unabhängig bleiben möchte?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1957037</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1957037</guid><dc:creator><![CDATA[anfänger01]]></dc:creator><pubDate>Fri, 24 Sep 2010 19:00:00 GMT</pubDate></item><item><title><![CDATA[Reply to Wozu braucht man solche Typedefs? on Fri, 24 Sep 2010 19:01:04 GMT]]></title><description><![CDATA[<p>Deswegen könnte er ja immer das Minimum gemeint haben.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1957038</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1957038</guid><dc:creator><![CDATA[blue-tec]]></dc:creator><pubDate>Fri, 24 Sep 2010 19:01:04 GMT</pubDate></item><item><title><![CDATA[Reply to Wozu braucht man solche Typedefs? on Fri, 24 Sep 2010 19:19:57 GMT]]></title><description><![CDATA[<p>anfänger01 schrieb:</p>
<blockquote>
<p>Könnte es sein, dass man damit je nach Zielsystem 32/64bit die Größen anpasst um die Grenzen konstant zu halten?</p>
<p>Muss ich so etwas machen wenn ich Plattform unabhängig bleiben möchte?</p>
</blockquote>
<p>Genau. Das ist so der übliche Weg, wie das gemacht wird. Es konzentrieren sich dann die plattformabhängigen Änderungen in einem einzigen File und nicht auf das gesamte Projekt. Somit muss nur diese eine Datei geändert und angepasst werden, dass die Typen stimmen und der Rest ist dann automatisch korrekt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1957040</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1957040</guid><dc:creator><![CDATA[drakon]]></dc:creator><pubDate>Fri, 24 Sep 2010 19:19:57 GMT</pubDate></item><item><title><![CDATA[Reply to Wozu braucht man solche Typedefs? on Fri, 24 Sep 2010 19:54:36 GMT]]></title><description><![CDATA[<p>padreigh schrieb:</p>
<blockquote>
<p>blue-tec schrieb:</p>
<blockquote>
<p>Ist denn nicht ein long mindestens 32bit groß?</p>
</blockquote>
<p>Ja schon, aber:</p>
<p>sizeof(type) liefert bei mir (linux64bit)</p>
<pre><code>bool           1 
char           1 
unsigned char  1 
long           8 
long long      8 
float          4 
double         8
</code></pre>
<pre><code>typedef long          Tint32;
typedef long long     Tint64;
</code></pre>
<p>..also suggerieren die Bezeichner zT weniger als sie dann sind ...</p>
</blockquote>
<p>Das ist ein Bug.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1957052</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1957052</guid><dc:creator><![CDATA[volkard]]></dc:creator><pubDate>Fri, 24 Sep 2010 19:54:36 GMT</pubDate></item></channel></rss>