<?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[Probleme mit #define]]></title><description><![CDATA[<p>Hi Leute<br />
Ich versuch mit #define ein bestimmten quelltext bereich zu öffnen wenn die Datei fehlt.<br />
Mein Problem ist das das nicht funktioniert kann mir jemand sagen was ich falsch mache.</p>
<pre><code class="language-cpp">int Game::new_game(std::string game_name, std::string game_path)
{
    int id;

    TiXmlDocument doc(&quot;./config/self.conf&quot;);

    doc.LoadFile();

    id = self_list();

    if(id == -1)
    {
        #define NEW_DATA
    }

    #ifdef NEW_DATA
    TiXmlElement data(&quot;MyGames&quot;);
    id=0;
    #endif

    TiXmlElement name(&quot;Game&quot;);
    name.SetAttribute(&quot;ID&quot;, id+1);
    name.SetAttribute(&quot;NAME&quot;, game_name.c_str());
    name.SetAttribute(&quot;PATH&quot;, game_path.c_str());

    #ifdef NEW_DATA
    data.InsertEndChild(name);
    doc.InsertEndChild(data);
    #else
    doc.InsertEndChild(name);
    #endif

    if(doc.SaveFile())
    {
        return -5;
    }

    return 0;
}
</code></pre>
<p>Grüße,<br />
Nico</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/274382/probleme-mit-define</link><generator>RSS for Node</generator><lastBuildDate>Thu, 27 Aug 2026 14:10:51 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/274382.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 25 Sep 2010 07:12:14 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Probleme mit #define on Sat, 25 Sep 2010 07:12:14 GMT]]></title><description><![CDATA[<p>Hi Leute<br />
Ich versuch mit #define ein bestimmten quelltext bereich zu öffnen wenn die Datei fehlt.<br />
Mein Problem ist das das nicht funktioniert kann mir jemand sagen was ich falsch mache.</p>
<pre><code class="language-cpp">int Game::new_game(std::string game_name, std::string game_path)
{
    int id;

    TiXmlDocument doc(&quot;./config/self.conf&quot;);

    doc.LoadFile();

    id = self_list();

    if(id == -1)
    {
        #define NEW_DATA
    }

    #ifdef NEW_DATA
    TiXmlElement data(&quot;MyGames&quot;);
    id=0;
    #endif

    TiXmlElement name(&quot;Game&quot;);
    name.SetAttribute(&quot;ID&quot;, id+1);
    name.SetAttribute(&quot;NAME&quot;, game_name.c_str());
    name.SetAttribute(&quot;PATH&quot;, game_path.c_str());

    #ifdef NEW_DATA
    data.InsertEndChild(name);
    doc.InsertEndChild(data);
    #else
    doc.InsertEndChild(name);
    #endif

    if(doc.SaveFile())
    {
        return -5;
    }

    return 0;
}
</code></pre>
<p>Grüße,<br />
Nico</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1957168</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1957168</guid><dc:creator><![CDATA[CCodex]]></dc:creator><pubDate>Sat, 25 Sep 2010 07:12:14 GMT</pubDate></item><item><title><![CDATA[Reply to Probleme mit #define on Sat, 25 Sep 2010 07:26:27 GMT]]></title><description><![CDATA[<p>Dir ist anscheinend nicht klar, dass Präprozessordirektiven zur Compile-Zeit verarbeitet werden. Eigentlich sogar noch davor. Das ist ein reines Text-Ersetzungswerkzeug.</p>
<p><a href="http://de.wikipedia.org/wiki/C-Pr%C3%A4prozessor" rel="nofollow">http://de.wikipedia.org/wiki/C-Präprozessor</a></p>
<p>Den Präprozessor interessiert es nicht, ob Du ein <code>#define</code> in einem <code>if(){}</code> Block rein schreibst. Er läuft über den Quelltext rüber, verrichtet seine Arbeit und präsentiert das Ergebnis (welches keine Präprozessordirektiven mehr enthält) dem eigentlichen Compiler.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1957169</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1957169</guid><dc:creator><![CDATA[krümelkacker]]></dc:creator><pubDate>Sat, 25 Sep 2010 07:26:27 GMT</pubDate></item><item><title><![CDATA[Reply to Probleme mit #define on Sat, 25 Sep 2010 07:36:53 GMT]]></title><description><![CDATA[<p>Aso dann hab ich das Prinzip nicht verstanden. Danke</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1957172</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1957172</guid><dc:creator><![CDATA[CCodex]]></dc:creator><pubDate>Sat, 25 Sep 2010 07:36:53 GMT</pubDate></item><item><title><![CDATA[Reply to Probleme mit #define on Sat, 25 Sep 2010 07:50:10 GMT]]></title><description><![CDATA[<p>Nehm doch einfach</p>
<pre><code class="language-cpp">const bool
</code></pre>
<p>und dann kannst ja überprüfen obs true oder false ist.<br />
Es ist empfehlenswert, generell</p>
<pre><code class="language-cpp">const
</code></pre>
<pre><code class="language-cpp">#define
</code></pre>
<p>vorzuziehen, also wos nur möglich ist lieber const anstatt define.</p>
<p>Lg freeG</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1957173</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1957173</guid><dc:creator><![CDATA[fr33g]]></dc:creator><pubDate>Sat, 25 Sep 2010 07:50:10 GMT</pubDate></item><item><title><![CDATA[Reply to Probleme mit #define on Sat, 25 Sep 2010 10:55:08 GMT]]></title><description><![CDATA[<p>Wie soll ihm hier ein <code>const bool</code> helfen?!<br />
Das ist ein ganz klarer Fall von einem ganz normalem <code>bool</code> .</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1957247</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1957247</guid><dc:creator><![CDATA[drakon]]></dc:creator><pubDate>Sat, 25 Sep 2010 10:55:08 GMT</pubDate></item><item><title><![CDATA[Reply to Probleme mit #define on Sat, 25 Sep 2010 11:04:03 GMT]]></title><description><![CDATA[<p>Ich hab ein bool variable genommen geht jetzt auch alles.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1957253</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1957253</guid><dc:creator><![CDATA[CCodex]]></dc:creator><pubDate>Sat, 25 Sep 2010 11:04:03 GMT</pubDate></item><item><title><![CDATA[Reply to Probleme mit #define on Sat, 25 Sep 2010 11:07:06 GMT]]></title><description><![CDATA[<p>drakon schrieb:</p>
<blockquote>
<p>Wie soll ihm hier ein <code>const bool</code> helfen?!</p>
</blockquote>
<pre><code class="language-cpp">const bool newData = (id == -1);
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1957255</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1957255</guid><dc:creator><![CDATA[Nexus]]></dc:creator><pubDate>Sat, 25 Sep 2010 11:07:06 GMT</pubDate></item><item><title><![CDATA[Reply to Probleme mit #define on Sat, 25 Sep 2010 11:19:15 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/12954">@Nexus</a><br />
Dein Tipp ist gut hab ich gleich mal eingebaut danke.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1957263</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1957263</guid><dc:creator><![CDATA[CCodex]]></dc:creator><pubDate>Sat, 25 Sep 2010 11:19:15 GMT</pubDate></item><item><title><![CDATA[Reply to Probleme mit #define on Sat, 25 Sep 2010 11:26:37 GMT]]></title><description><![CDATA[<p>Lesen, posten. Ich sollte mich wirklich wieder dran halten.. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f644.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_rolling_eyes"
      title=":rolling_eyes:"
      alt="🙄"
    /><br />
Da hat mich das define wirklich ein wenig verwirrt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1957266</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1957266</guid><dc:creator><![CDATA[drakon]]></dc:creator><pubDate>Sat, 25 Sep 2010 11:26:37 GMT</pubDate></item></channel></rss>