<?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[Ausgelagerte #ifdefs und Templates]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich lagere alle meine #ifdefs in separaten Dateien aus die ich dann über inline in den ifdef-freien code einbinde. Alles funktioniert solange ich keine Templates benutze. Ich Moment steh ich auf dem Schlauch wie ich denn template-basiert auslagern kann.</p>
<p>Ich habe folgenden code:</p>
<p>Meine xyz.hpp sieht so aus</p>
<pre><code class="language-cpp">#ifdef MYFLAG
#    include variante1/xyz1.hpp
#else
#    include variante2/xyz.hpp
#endif
</code></pre>
<p>variante1/xyz1.hpp</p>
<pre><code class="language-cpp">inline void foo(CL&lt;T&gt;* cl, const int a)
{
   // Mache was
}
</code></pre>
<p>variante2/xyz2.hpp</p>
<pre><code class="language-cpp">inline void foo(CL&lt;T&gt;* cl, const int a){ }
</code></pre>
<p>Das ist ifdef-freier code</p>
<pre><code class="language-cpp">#include &quot;xyz.hpp&quot;

int main(int argc, int* argv[])
{
    CL&lt;double&gt; cl = new CL&lt;double&gt;();
    int a = 4;

    foo(cl,a);
}
</code></pre>
<p>Meldung des compilers:</p>
<pre><code>there are no arguments to ‘foo’ that depend on a template parameter, so a declaration of ‘foo’ must be available
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/240008/ausgelagerte-ifdefs-und-templates</link><generator>RSS for Node</generator><lastBuildDate>Tue, 22 Sep 2026 00:44:13 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/240008.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 30 Apr 2009 15:25:15 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Ausgelagerte #ifdefs und Templates on Thu, 30 Apr 2009 15:25:15 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich lagere alle meine #ifdefs in separaten Dateien aus die ich dann über inline in den ifdef-freien code einbinde. Alles funktioniert solange ich keine Templates benutze. Ich Moment steh ich auf dem Schlauch wie ich denn template-basiert auslagern kann.</p>
<p>Ich habe folgenden code:</p>
<p>Meine xyz.hpp sieht so aus</p>
<pre><code class="language-cpp">#ifdef MYFLAG
#    include variante1/xyz1.hpp
#else
#    include variante2/xyz.hpp
#endif
</code></pre>
<p>variante1/xyz1.hpp</p>
<pre><code class="language-cpp">inline void foo(CL&lt;T&gt;* cl, const int a)
{
   // Mache was
}
</code></pre>
<p>variante2/xyz2.hpp</p>
<pre><code class="language-cpp">inline void foo(CL&lt;T&gt;* cl, const int a){ }
</code></pre>
<p>Das ist ifdef-freier code</p>
<pre><code class="language-cpp">#include &quot;xyz.hpp&quot;

int main(int argc, int* argv[])
{
    CL&lt;double&gt; cl = new CL&lt;double&gt;();
    int a = 4;

    foo(cl,a);
}
</code></pre>
<p>Meldung des compilers:</p>
<pre><code>there are no arguments to ‘foo’ that depend on a template parameter, so a declaration of ‘foo’ must be available
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1703686</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1703686</guid><dc:creator><![CDATA[gruppa]]></dc:creator><pubDate>Thu, 30 Apr 2009 15:25:15 GMT</pubDate></item><item><title><![CDATA[Reply to Ausgelagerte #ifdefs und Templates on Thu, 30 Apr 2009 15:48:43 GMT]]></title><description><![CDATA[<p>Du hast foo nicht als Funktionstemplate deklariert (oder hast es nicht als solches gepostet)</p>
<pre><code class="language-cpp">CL&lt;double&gt; cl = new CL&lt;double&gt;();
</code></pre>
<p>Ich bezweifle dass das compiliert...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1703700</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1703700</guid><dc:creator><![CDATA[pumuckl]]></dc:creator><pubDate>Thu, 30 Apr 2009 15:48:43 GMT</pubDate></item><item><title><![CDATA[Reply to Ausgelagerte #ifdefs und Templates on Thu, 30 Apr 2009 15:49:17 GMT]]></title><description><![CDATA[<p>Ich sehe da auf die Schnelle zwei Fehlermöglichkeiten, kommt darauf an, ob das nicht Tippfehler sind oder ob du etwas vergessen hast.</p>
<p>[quote=&quot;gruppa&quot;]</p>
<pre><code class="language-cpp">#ifdef MYFLAG
#    include variante1/xyz1.hpp
#else
#    include variante2/xyz.hpp
#endif
</code></pre>
<p>Da fehlen doch Anführungszeichen, zudem sollte es beim Zweiten nicht <code>xyz2.hpp</code> lauten?</p>
<p>gruppa schrieb:</p>
<blockquote>
<p>variante1/xyz1.hpp</p>
<pre><code class="language-cpp">inline void foo(CL&lt;T&gt;* cl, const int a)
{
   // Mache was
}
</code></pre>
<p>variante2/xyz2.hpp</p>
<pre><code class="language-cpp">inline void foo(CL&lt;T&gt;* cl, const int a){ }
</code></pre>
</blockquote>
<p>Fehlen da nicht noch jeweils ein <code>template&lt;typename T&gt;</code> davor?</p>
<p>Grüssli</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1703701</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1703701</guid><dc:creator><![CDATA[Dravere]]></dc:creator><pubDate>Thu, 30 Apr 2009 15:49:17 GMT</pubDate></item><item><title><![CDATA[Reply to Ausgelagerte #ifdefs und Templates on Thu, 30 Apr 2009 16:27:11 GMT]]></title><description><![CDATA[<p>also erstmal danke für die antworten.</p>
<p>Ja ich hab da versucht ein minimalbeispiel auf die schnell aus dem kopf zu posten weil ich etwas mehr code hab. Die Anführungszeichen fehlen da ja. Und das template &lt;class T&gt; hab ichvergessen sorry.</p>
<p>Ich bemerke dass mein Code wo anders das Problem hat und zwar bei sowas:</p>
<pre><code class="language-cpp">template&lt;class T&gt; CL&lt;T&gt;::CL(int a)
{
   bar(a);
}
</code></pre>
<p>wobei bar() in einem der variante1/xyz1.hpp definiert sind</p>
<pre><code class="language-cpp">bar(int a)
{
   //do something...
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1703722</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1703722</guid><dc:creator><![CDATA[gruppa]]></dc:creator><pubDate>Thu, 30 Apr 2009 16:27:11 GMT</pubDate></item><item><title><![CDATA[Reply to Ausgelagerte #ifdefs und Templates on Thu, 30 Apr 2009 16:30:22 GMT]]></title><description><![CDATA[<p>gruppa schrieb:</p>
<blockquote>
<p>Ja ich hab da versucht ein minimalbeispiel auf die schnell aus dem kopf zu posten weil ich etwas mehr code hab.</p>
</blockquote>
<p>Häufig bringt der Versuch, das Minimalbeispiel zu <em>compilieren</em> schon den Aha-Effekt. Das erspart dir dann die Wartezeit bis jemand antwortet und uns ersparts das Nachbessern deiner Tippfehler wenn wir versuchen deinen Fehler nachzustellen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1703725</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1703725</guid><dc:creator><![CDATA[pumuckl]]></dc:creator><pubDate>Thu, 30 Apr 2009 16:30:22 GMT</pubDate></item><item><title><![CDATA[Reply to Ausgelagerte #ifdefs und Templates on Thu, 30 Apr 2009 16:44:12 GMT]]></title><description><![CDATA[<p>hmm ja ok. Was kann man denn machen wenn man in einer template funktion eine funktion aufruft die eben nicht template-abhängige paramter hat sondern komplett tamplate frei ist?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1703735</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1703735</guid><dc:creator><![CDATA[gruppa]]></dc:creator><pubDate>Thu, 30 Apr 2009 16:44:12 GMT</pubDate></item><item><title><![CDATA[Reply to Ausgelagerte #ifdefs und Templates on Thu, 30 Apr 2009 16:54:08 GMT]]></title><description><![CDATA[<p>gruppa schrieb:</p>
<blockquote>
<p>Was kann man denn machen wenn man in einer template funktion eine funktion aufruft die eben nicht template-abhängige paramter hat sondern komplett tamplate frei ist?</p>
</blockquote>
<p>Diese aufrufen? <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /></p>
<p>Wo liegt dein Problem genau? Du musst halt Funktionen vor ihrem Aufruf deklarieren.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1703742</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1703742</guid><dc:creator><![CDATA[Nexus]]></dc:creator><pubDate>Thu, 30 Apr 2009 16:54:08 GMT</pubDate></item><item><title><![CDATA[Reply to Ausgelagerte #ifdefs und Templates on Thu, 30 Apr 2009 17:05:40 GMT]]></title><description><![CDATA[<p>mein problem liegt genau hierin:</p>
<pre><code class="language-cpp">template &lt;class T&gt;
Foo&lt;T&gt;::Foo(int a)
{
   bar(a);
}
</code></pre>
<p>und bar() steht so in einem der variante* header:</p>
<pre><code class="language-cpp">inline void bar(int a) {
   //do something
}
</code></pre>
<p>und die meldung ist eben:</p>
<pre><code>error: there are no arguments to 'bar’ that depend on a template parameter, so a declaration of ‘bar’ must be available
</code></pre>
<p>aber wie soll ich dann template-freie funktionen in einer template-funktion aufrufen oder hängt das mit den ausgelagerten ifdefs zusammen?</p>
<p>Danke</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1703756</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1703756</guid><dc:creator><![CDATA[gruppa]]></dc:creator><pubDate>Thu, 30 Apr 2009 17:05:40 GMT</pubDate></item><item><title><![CDATA[Reply to Ausgelagerte #ifdefs und Templates on Thu, 30 Apr 2009 17:11:06 GMT]]></title><description><![CDATA[<p>Ist <code>bar()</code> zu der Zeit des Aufrufs bekannt, sprich wurde die Funktion deklariert?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1703759</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1703759</guid><dc:creator><![CDATA[Nexus]]></dc:creator><pubDate>Thu, 30 Apr 2009 17:11:06 GMT</pubDate></item><item><title><![CDATA[Reply to Ausgelagerte #ifdefs und Templates on Thu, 30 Apr 2009 17:17:20 GMT]]></title><description><![CDATA[<p>gruppa schrieb:</p>
<blockquote>
<p>... oder hängt das mit den ausgelagerten ifdefs zusammen?</p>
</blockquote>
<p>Wenn der Kompiler kompiliert, hat der Präprozessor bereits gewütet. Also ist es eher unwahrscheinlich, dass es etwas direkt mit dem <code>ifdef</code> zu tun hat. Ausser du hast die MAKROs falsch gesetzt, wodurch die Deklaration nie eingebunden wurde. Da hilft es manchmal den Output des Präprozessors anzuschauen.</p>
<p>Ansonsten probier mal den Aufruf von <code>bar</code> genau zu spezifizieren. Also die genaue Angabe zu setzen, in welchem Namensraus sich <code>bar</code> befindet.</p>
<p>Grüssli</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1703762</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1703762</guid><dc:creator><![CDATA[Dravere]]></dc:creator><pubDate>Thu, 30 Apr 2009 17:17:20 GMT</pubDate></item><item><title><![CDATA[Reply to Ausgelagerte #ifdefs und Templates on Mon, 04 May 2009 10:12:33 GMT]]></title><description><![CDATA[<blockquote>
<p>da hilft es manchmal den Output des Präprozessors anzuschauen.</p>
</blockquote>
<p>wie kann ich das tun?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1705187</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1705187</guid><dc:creator><![CDATA[gruppa]]></dc:creator><pubDate>Mon, 04 May 2009 10:12:33 GMT</pubDate></item><item><title><![CDATA[Reply to Ausgelagerte #ifdefs und Templates on Mon, 04 May 2009 10:29:13 GMT]]></title><description><![CDATA[<p>Wird bar() in beiden Varianten genutzt oder nur in einer. Ist es denn in beiden Varianten deklariert?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1705194</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1705194</guid><dc:creator><![CDATA[Chris++ 0]]></dc:creator><pubDate>Mon, 04 May 2009 10:29:13 GMT</pubDate></item><item><title><![CDATA[Reply to Ausgelagerte #ifdefs und Templates on Mon, 04 May 2009 11:36:31 GMT]]></title><description><![CDATA[<p>gruppa schrieb:</p>
<blockquote>
<blockquote>
<p>da hilft es manchmal den Output des Präprozessors anzuschauen.</p>
</blockquote>
<p>wie kann ich das tun?</p>
</blockquote>
<p>hängt von deinem Compiler ab. Den meisten Compilern kann man einen Kommandozeilenparameter mitgeben der dafür sorgt, dass nur der Präprozessordurchlauf erfolgt und der entsprechende Output ausgegeben wird.</p>
<p>=&gt; Konsutliere die Doku/Hilfe/man-Pages deines Compilers</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1705239</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1705239</guid><dc:creator><![CDATA[pumuckl]]></dc:creator><pubDate>Mon, 04 May 2009 11:36:31 GMT</pubDate></item><item><title><![CDATA[Reply to Ausgelagerte #ifdefs und Templates on Mon, 04 May 2009 18:45:26 GMT]]></title><description><![CDATA[<blockquote>
<p>Wird bar() in beiden Varianten genutzt oder nur in einer. Ist es denn in beiden Varianten deklariert?</p>
</blockquote>
<p>Ja - bar() wird in beiden varianten definiert und deklariert.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1705530</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1705530</guid><dc:creator><![CDATA[gruppa]]></dc:creator><pubDate>Mon, 04 May 2009 18:45:26 GMT</pubDate></item><item><title><![CDATA[Reply to Ausgelagerte #ifdefs und Templates on Mon, 04 May 2009 18:51:35 GMT]]></title><description><![CDATA[<p>und bar() sollte zu der zeit bekannt sein weil im header wo ich ich den konstruktor habe wird oben ein weiterer header eingebunden in dem dann je nach flag variante1 oder variante2 eingebunden wird. Somit sollte bar() verfügbar sein....</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1705533</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1705533</guid><dc:creator><![CDATA[gruppa]]></dc:creator><pubDate>Mon, 04 May 2009 18:51:35 GMT</pubDate></item><item><title><![CDATA[Reply to Ausgelagerte #ifdefs und Templates on Mon, 04 May 2009 18:59:26 GMT]]></title><description><![CDATA[<p>hmm...ich hab nen link gefunden worin über this-&gt;bar() das ding zum funzen kommt....wäre das valide bzw. ich versuche noch zu verstehen warum es so geht....</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1705538</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1705538</guid><dc:creator><![CDATA[gruppa]]></dc:creator><pubDate>Mon, 04 May 2009 18:59:26 GMT</pubDate></item><item><title><![CDATA[Reply to Ausgelagerte #ifdefs und Templates on Mon, 04 May 2009 20:08:08 GMT]]></title><description><![CDATA[<p>Ich habe ein weiteres problem und das passt hierhin deswegen möchte ich nicht unbedingt einen neuen thread aufmachen:</p>
<p>Ich bekomme seltsamerweise ein &quot;VEC&quot; has not been declared wenn ich in den variante*.hpp headern einen typ &quot;VEC&quot; in der signatur verwende. Und das obwohl ich die klasse bzw. den header einbinde vorher!</p>
<p>also sowas:</p>
<pre><code class="language-cpp">//variante1.hpp

template &lt;class T&gt; inline void bar(VEC&lt;T&gt;* v)
{

}
</code></pre>
<p>bar() benutze ich dann z.B. im Konstuktor von Foo wie oben im code dargestellt - natürlich mit richtigem VEC Parameter als übergabe.</p>
<p>Nur warum bekommei ch ein has not been declared obwohl ich VEC einbinde als Klasse? Woran könnte das liegen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1705564</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1705564</guid><dc:creator><![CDATA[gruppa]]></dc:creator><pubDate>Mon, 04 May 2009 20:08:08 GMT</pubDate></item><item><title><![CDATA[Reply to Ausgelagerte #ifdefs und Templates on Tue, 05 May 2009 10:06:40 GMT]]></title><description><![CDATA[<p>*push</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1705726</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1705726</guid><dc:creator><![CDATA[gruppa]]></dc:creator><pubDate>Tue, 05 May 2009 10:06:40 GMT</pubDate></item><item><title><![CDATA[Reply to Ausgelagerte #ifdefs und Templates on Tue, 05 May 2009 14:09:02 GMT]]></title><description><![CDATA[<p>was sagt dir denn die fehlermeldung?</p>
<p>evtl steht da ja was von typename?<br />
scho ma damit rumprobiert? gibt ja nu nich so viele stellen, wo man das hinsetzen könnte, wo es sinn macht - und es steht so gar in der fehlermeldung und sollte eigtl auch genug themen dazu hier und vor allem bei <a href="http://www.google.de" rel="nofollow">www.google.de</a> geben ^^</p>
<p>bb</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1705923</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1705923</guid><dc:creator><![CDATA[unskilled]]></dc:creator><pubDate>Tue, 05 May 2009 14:09:02 GMT</pubDate></item></channel></rss>