<?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[Makro Template]]></title><description><![CDATA[<p>Hi,<br />
Ich würde gerne Folgendes durch den Präprozessor machen lassen.<br />
Ohne Konstanten zu deklarieren.</p>
<pre><code class="language-cpp">#define FILE_BUFFER_SIZE_1 10
#define FILE_BUFFER_SIZE_2 10000
#define FILE_BUFFER_SIZE_3 10000

#define  free_bytes(x) (FILE_BUFFER_SIZE_(x)+Buffer_ptr[x]-Buffer_pos_ptr[x])
</code></pre>
<p>Und dann eben schreiben können</p>
<pre><code class="language-cpp">free_bytes(1);
free_bytes(2);
free_bytes(3);
</code></pre>
<p><div class="plugin-markdown"><input type="checkbox" id="checkbox247515" checked="true" /><label for="checkbox247515">und Buffer_pos_ptr[x] sind arrays.</label></div><br />
Beim kopilieren bekomme ich die Fehlermeldung:</p>
<p>Fehler: es gibt keine Argumente für »FILE_BUFFER_SIZE_«, die von einem Templateparameter abhängen, weshalb eine Deklaration von »FILE_BUFFER_SIZE_« verfügbar sein muss<br />
matrix.cpp:60: Fehler: (mit »-fpermissive« wird G++ den Code akzeptieren, aber die Verwendung eines nicht deklarierten Namens ist veraltet)<br />
make: *** [matrix.o] Fehler 1</p>
<p>Mit -fpermissive funktionierts auch nicht. Ihm fehlt in jedem Fall die dekleration von FILE_BUFFER_SIZE_</p>
<p>--------------------------------------------------------------------------<br />
Was funktioniert ist:</p>
<pre><code class="language-cpp">namespace buffer_size
    {
        const long int buf_size[3]={FILE_BUFFER_SIZE_1, FILE_BUFFER_SIZE_2 ,FILE_BUFFER_SIZE_3};
    }
</code></pre>
<p>und dann das makro</p>
<pre><code class="language-cpp">#define  free_bytes(x) (buffer_size::buf_size[x]+Buffer_ptr[x]-Buffer_pos_ptr[x])
</code></pre>
<p>Ich würde gerne aber die Konstanten einsparen.<br />
Gruß</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/248799/makro-template</link><generator>RSS for Node</generator><lastBuildDate>Wed, 16 Sep 2026 20:19:35 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/248799.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 29 Aug 2009 12:06:57 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Makro Template on Sat, 29 Aug 2009 12:06:57 GMT]]></title><description><![CDATA[<p>Hi,<br />
Ich würde gerne Folgendes durch den Präprozessor machen lassen.<br />
Ohne Konstanten zu deklarieren.</p>
<pre><code class="language-cpp">#define FILE_BUFFER_SIZE_1 10
#define FILE_BUFFER_SIZE_2 10000
#define FILE_BUFFER_SIZE_3 10000

#define  free_bytes(x) (FILE_BUFFER_SIZE_(x)+Buffer_ptr[x]-Buffer_pos_ptr[x])
</code></pre>
<p>Und dann eben schreiben können</p>
<pre><code class="language-cpp">free_bytes(1);
free_bytes(2);
free_bytes(3);
</code></pre>
<p><div class="plugin-markdown"><input type="checkbox" id="checkbox247515" checked="true" /><label for="checkbox247515">und Buffer_pos_ptr[x] sind arrays.</label></div><br />
Beim kopilieren bekomme ich die Fehlermeldung:</p>
<p>Fehler: es gibt keine Argumente für »FILE_BUFFER_SIZE_«, die von einem Templateparameter abhängen, weshalb eine Deklaration von »FILE_BUFFER_SIZE_« verfügbar sein muss<br />
matrix.cpp:60: Fehler: (mit »-fpermissive« wird G++ den Code akzeptieren, aber die Verwendung eines nicht deklarierten Namens ist veraltet)<br />
make: *** [matrix.o] Fehler 1</p>
<p>Mit -fpermissive funktionierts auch nicht. Ihm fehlt in jedem Fall die dekleration von FILE_BUFFER_SIZE_</p>
<p>--------------------------------------------------------------------------<br />
Was funktioniert ist:</p>
<pre><code class="language-cpp">namespace buffer_size
    {
        const long int buf_size[3]={FILE_BUFFER_SIZE_1, FILE_BUFFER_SIZE_2 ,FILE_BUFFER_SIZE_3};
    }
</code></pre>
<p>und dann das makro</p>
<pre><code class="language-cpp">#define  free_bytes(x) (buffer_size::buf_size[x]+Buffer_ptr[x]-Buffer_pos_ptr[x])
</code></pre>
<p>Ich würde gerne aber die Konstanten einsparen.<br />
Gruß</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1768726</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1768726</guid><dc:creator><![CDATA[AlexXXx]]></dc:creator><pubDate>Sat, 29 Aug 2009 12:06:57 GMT</pubDate></item><item><title><![CDATA[Reply to Makro Template on Sat, 29 Aug 2009 12:10:20 GMT]]></title><description><![CDATA[<p>Nimm keine defines sondern konstanten. In deinem Fall ein konstantes Array.</p>
<p>Was wahrscheinlich auch gehen wuerde waeren Enums.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1768729</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1768729</guid><dc:creator><![CDATA[The-Kenny]]></dc:creator><pubDate>Sat, 29 Aug 2009 12:10:20 GMT</pubDate></item><item><title><![CDATA[Reply to Makro Template on Sat, 29 Aug 2009 12:13:01 GMT]]></title><description><![CDATA[<p><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="🙂"
    /><br />
Ich such doch nach einer Lösung ohne die Selben. Ich hoffe daß es duch templates irgendwie geht. (Auch wegen der compiler meldung)<br />
Gruß</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1768731</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1768731</guid><dc:creator><![CDATA[AlexXXx]]></dc:creator><pubDate>Sat, 29 Aug 2009 12:13:01 GMT</pubDate></item><item><title><![CDATA[Reply to Makro Template on Sat, 29 Aug 2009 12:14:47 GMT]]></title><description><![CDATA[<p>AlexXXx schrieb:</p>
<blockquote>
<p>Ich such doch nach einer Lösung ohne die Selben.</p>
</blockquote>
<p>Aus welchem Grund?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1768733</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1768733</guid><dc:creator><![CDATA[pumuckl]]></dc:creator><pubDate>Sat, 29 Aug 2009 12:14:47 GMT</pubDate></item><item><title><![CDATA[Reply to Makro Template on Sat, 29 Aug 2009 12:17:31 GMT]]></title><description><![CDATA[<p>Ich habs jetzt nicht getestestet, aber FILE_BUFFER_SIZE_##x statt FILE_BUFFER_SIZE_(x) sollte funktionieren. Dann darf aber bei free_bytes als Parameter nur eine hardgecodete Zahl angegeben werden, keine Variable und kein Ausdruck.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1768734</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1768734</guid><dc:creator><![CDATA[ipsec]]></dc:creator><pubDate>Sat, 29 Aug 2009 12:17:31 GMT</pubDate></item><item><title><![CDATA[Reply to Makro Template on Sat, 29 Aug 2009 12:20:09 GMT]]></title><description><![CDATA[<p>Jetzt aus garkeinem mehr.=)<br />
Hat sich erledigt. Wußte nicht daß der comiler so effizient mit const variablen umgehen kann.<br />
Gruß</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1768735</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1768735</guid><dc:creator><![CDATA[AlexXXx]]></dc:creator><pubDate>Sat, 29 Aug 2009 12:20:09 GMT</pubDate></item><item><title><![CDATA[Reply to Makro Template on Sat, 29 Aug 2009 12:26:23 GMT]]></title><description><![CDATA[<p>@XMaster<br />
Hey danke da haut hin.<br />
Gibts auch ne Variante wo x nicht hard coded sein muß??<br />
Würde gerne ne variable nehmen.<br />
also ohne</p>
<pre><code class="language-cpp">if(variable==1)
makro(1)
if(cariable==2)
makro(2)
.
.
.
</code></pre>
<p>Gruß</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1768738</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1768738</guid><dc:creator><![CDATA[AlexXXx]]></dc:creator><pubDate>Sat, 29 Aug 2009 12:26:23 GMT</pubDate></item><item><title><![CDATA[Reply to Makro Template on Sat, 29 Aug 2009 12:46:28 GMT]]></title><description><![CDATA[<p>Nein. Mit defines nicht. Nimm, wie schon gesagt das Array..</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1768744</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1768744</guid><dc:creator><![CDATA[drakon]]></dc:creator><pubDate>Sat, 29 Aug 2009 12:46:28 GMT</pubDate></item></channel></rss>