<?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[Fehlermeldung, Template]]></title><description><![CDATA[<p>Hallo!</p>
<p>Könnt Ihr mit dieser Fehlermeldung etwas anfangen?</p>
<p>SimplePool.h: In member function ‘void SimplePool&lt;T&gt;::alloc(int)’:<br />
SimplePool.h:93: error: there are no arguments to ‘malloc’ that depend on a template parameter, so a declaration of ‘malloc’ must be available<br />
SimplePool.h:93: note: (if you use ‘-fpermissive’, G++ will accept your code, but allowing the use of an undeclared name is deprecated)</p>
<pre><code class="language-cpp">template&lt;class T&gt; 
void SimplePool&lt;T&gt;::alloc(int num)
{
	unsigned siz=num*sizeof(T);

	malloc(siz);
}
</code></pre>
<p>Die Zeile mit dem malloc hängt doch von keinem Template-Parameter ab, sondern<br />
nur jene mit siz=.. Die Klasse wird testhalber als globale Variable im<br />
main.cpp wie folgt instanziert:</p>
<p>SimplePool&lt;TestClass&gt; vertexSimplePool;</p>
<p>Die Methode macht so natürlich keinen Sinn. Ist nur ein minimales Beispiel.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/282170/fehlermeldung-template</link><generator>RSS for Node</generator><lastBuildDate>Sun, 23 Aug 2026 08:56:31 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/282170.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 15 Feb 2011 11:27:02 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Fehlermeldung, Template on Tue, 15 Feb 2011 11:27:02 GMT]]></title><description><![CDATA[<p>Hallo!</p>
<p>Könnt Ihr mit dieser Fehlermeldung etwas anfangen?</p>
<p>SimplePool.h: In member function ‘void SimplePool&lt;T&gt;::alloc(int)’:<br />
SimplePool.h:93: error: there are no arguments to ‘malloc’ that depend on a template parameter, so a declaration of ‘malloc’ must be available<br />
SimplePool.h:93: note: (if you use ‘-fpermissive’, G++ will accept your code, but allowing the use of an undeclared name is deprecated)</p>
<pre><code class="language-cpp">template&lt;class T&gt; 
void SimplePool&lt;T&gt;::alloc(int num)
{
	unsigned siz=num*sizeof(T);

	malloc(siz);
}
</code></pre>
<p>Die Zeile mit dem malloc hängt doch von keinem Template-Parameter ab, sondern<br />
nur jene mit siz=.. Die Klasse wird testhalber als globale Variable im<br />
main.cpp wie folgt instanziert:</p>
<p>SimplePool&lt;TestClass&gt; vertexSimplePool;</p>
<p>Die Methode macht so natürlich keinen Sinn. Ist nur ein minimales Beispiel.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2021210</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2021210</guid><dc:creator><![CDATA[t]]></dc:creator><pubDate>Tue, 15 Feb 2011 11:27:02 GMT</pubDate></item><item><title><![CDATA[Reply to Fehlermeldung, Template on Tue, 15 Feb 2011 11:32:14 GMT]]></title><description><![CDATA[<p>Kann es sein, dass einfach das include von cstdlib fehlt?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2021211</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2021211</guid><dc:creator><![CDATA[Braunstein]]></dc:creator><pubDate>Tue, 15 Feb 2011 11:32:14 GMT</pubDate></item><item><title><![CDATA[Reply to Fehlermeldung, Template on Tue, 15 Feb 2011 11:39:06 GMT]]></title><description><![CDATA[<p>Hier ist doch C++?<br />
Warum dann malloc und nicht new?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2021212</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2021212</guid><dc:creator><![CDATA[f.-th.]]></dc:creator><pubDate>Tue, 15 Feb 2011 11:39:06 GMT</pubDate></item><item><title><![CDATA[Reply to Fehlermeldung, Template on Tue, 15 Feb 2011 11:42:53 GMT]]></title><description><![CDATA[<p>Genau das steht ja auch in der Fehlermeldung.</p>
<p>t schrieb:</p>
<blockquote>
<p>Die Zeile mit dem malloc hängt doch von keinem Template-Parameter ab, sondern<br />
nur jene mit siz=..</p>
</blockquote>
<p>Da der Name &quot;malloc&quot; eben KEIN &quot;abhängiger Name&quot; ist, muss er an der Stelle wo das Template definiert wird bereits bekannt sein.<br />
Und das ist er nicht, weil du ein #include vergessen hast.</p>
<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/1387">@Braunstein</a>: jo, genau <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/2021217</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2021217</guid><dc:creator><![CDATA[hustbaer]]></dc:creator><pubDate>Tue, 15 Feb 2011 11:42:53 GMT</pubDate></item><item><title><![CDATA[Reply to Fehlermeldung, Template on Tue, 15 Feb 2011 11:55:34 GMT]]></title><description><![CDATA[<p>f.-th. schrieb:</p>
<blockquote>
<p>Hier ist doch C++?<br />
Warum dann malloc und nicht new?</p>
</blockquote>
<p>Weil's ein Memory Pool ist, dessen Zweck das Vermeiden von new ist.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2021220</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2021220</guid><dc:creator><![CDATA[t]]></dc:creator><pubDate>Tue, 15 Feb 2011 11:55:34 GMT</pubDate></item><item><title><![CDATA[Reply to Fehlermeldung, Template on Tue, 15 Feb 2011 11:58:07 GMT]]></title><description><![CDATA[<p>Braunstein schrieb:</p>
<blockquote>
<p>Kann es sein, dass einfach das include von cstdlib fehlt?</p>
</blockquote>
<p>Das ganze hat - instanziert aus einer anderen Klasse heraus - bereits<br />
funktioniert, obwohl dort auch kein cstdlib inkludiert wurde. Das #include<br />
ist dort wohl irgendwo 'quer' dahergekommen, daher habe ich nicht gleich<br />
drauf geschlossen. Vielen Dank!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2021221</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2021221</guid><dc:creator><![CDATA[t]]></dc:creator><pubDate>Tue, 15 Feb 2011 11:58:07 GMT</pubDate></item><item><title><![CDATA[Reply to Fehlermeldung, Template on Tue, 15 Feb 2011 12:25:32 GMT]]></title><description><![CDATA[<p>t schrieb:</p>
<blockquote>
<p>f.-th. schrieb:</p>
<blockquote>
<p>Hier ist doch C++?<br />
Warum dann malloc und nicht new?</p>
</blockquote>
<p>Weil's ein Memory Pool ist, dessen Zweck das Vermeiden von new ist.</p>
</blockquote>
<p>Hä?<br />
Wieso ist new() mehr böse als malloc()?</p>
<p>&quot;Wieso läufst du?&quot; - &quot;Weil ich nicht rennen will!&quot;<br />
... hä? <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>
]]></description><link>https://www.c-plusplus.net/forum/post/2021231</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2021231</guid><dc:creator><![CDATA[hustbaer]]></dc:creator><pubDate>Tue, 15 Feb 2011 12:25:32 GMT</pubDate></item><item><title><![CDATA[Reply to Fehlermeldung, Template on Tue, 15 Feb 2011 13:54:47 GMT]]></title><description><![CDATA[<p>hustbaer schrieb:</p>
<blockquote>
<p>Hä?<br />
Wieso ist new() mehr böse als malloc()?</p>
</blockquote>
<p>malloc() ruft Constructor/Destructor nicht auf. Das ist im vorliegenden Fall<br />
erwünscht.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2021283</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2021283</guid><dc:creator><![CDATA[t]]></dc:creator><pubDate>Tue, 15 Feb 2011 13:54:47 GMT</pubDate></item><item><title><![CDATA[Reply to Fehlermeldung, Template on Tue, 15 Feb 2011 15:03:27 GMT]]></title><description><![CDATA[<p><code>new char[size]</code></p>
<p>...?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2021330</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2021330</guid><dc:creator><![CDATA[hustbaer]]></dc:creator><pubDate>Tue, 15 Feb 2011 15:03:27 GMT</pubDate></item><item><title><![CDATA[Reply to Fehlermeldung, Template on Tue, 15 Feb 2011 19:15:18 GMT]]></title><description><![CDATA[<p>hustbaer schrieb:</p>
<blockquote>
<p><code>new char[size]</code></p>
<p>...?</p>
</blockquote>
<p>Okay, das geht auch.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2021486</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2021486</guid><dc:creator><![CDATA[t]]></dc:creator><pubDate>Tue, 15 Feb 2011 19:15:18 GMT</pubDate></item><item><title><![CDATA[Reply to Fehlermeldung, Template on Tue, 15 Feb 2011 23:29:37 GMT]]></title><description><![CDATA[<p>Oder einfach <code>operator new</code> aufrufen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2021625</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2021625</guid><dc:creator><![CDATA[Nexus]]></dc:creator><pubDate>Tue, 15 Feb 2011 23:29:37 GMT</pubDate></item></channel></rss>