<?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[Lambda Aufruf Konvention]]></title><description><![CDATA[<p>Ist es möglich, einer Lambda-Funktion eine calling convention anzugeben?<br />
Wenn ja, welche Compiler unterstützen dies bereits?</p>
<p>Ich muss z.B. eine Funktion mit __stdcall übergeben, Lambdas werden allerdings immer mit __cdecl erstellt.</p>
<pre><code>cannot convert 'avisynth_c_plugin_init(AVS_ScriptEnvironment*)::&lt;lambda(AVS_ScriptEnvironment*, AVS_Value, void*)&gt;' to 'AVS_ApplyFunc {aka AVS_Value (__attribute__((__stdcall__)) *)(AVS_ScriptEnvironment*, AVS_Value, void*)}'
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/320889/lambda-aufruf-konvention</link><generator>RSS for Node</generator><lastBuildDate>Wed, 22 Jul 2026 14:06:58 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/320889.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 16 Oct 2013 08:01:46 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Lambda Aufruf Konvention on Wed, 16 Oct 2013 08:07:28 GMT]]></title><description><![CDATA[<p>Ist es möglich, einer Lambda-Funktion eine calling convention anzugeben?<br />
Wenn ja, welche Compiler unterstützen dies bereits?</p>
<p>Ich muss z.B. eine Funktion mit __stdcall übergeben, Lambdas werden allerdings immer mit __cdecl erstellt.</p>
<pre><code>cannot convert 'avisynth_c_plugin_init(AVS_ScriptEnvironment*)::&lt;lambda(AVS_ScriptEnvironment*, AVS_Value, void*)&gt;' to 'AVS_ApplyFunc {aka AVS_Value (__attribute__((__stdcall__)) *)(AVS_ScriptEnvironment*, AVS_Value, void*)}'
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2360624</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2360624</guid><dc:creator><![CDATA[Youka]]></dc:creator><pubDate>Wed, 16 Oct 2013 08:07:28 GMT</pubDate></item><item><title><![CDATA[Reply to Lambda Aufruf Konvention on Wed, 16 Oct 2013 08:25:24 GMT]]></title><description><![CDATA[<p>Ein Lambda-Ausdruck hat den Typ des entsprechenden <em>closure type</em>s, welcher einfach eine Klasse mit allen gecaptureten Objekten und Referenzen ist. Diese Klasse überlädt den Funktionsoperator, also <code>operator()</code> .</p>
<p>Desweiteren kannst du bei einem Lambda-Ausdruck auch Attribute festlegen, welche dann dem besagten Funktionsoperator mitgegeben werden:</p>
<blockquote>
<p>An <em>attribute-specifier-seq</em> in a lambda-declarator appertains to the type of the corresponding function call operator.</p>
</blockquote>
<p>Das sieht so aus:</p>
<pre><code>auto l = []() &lsqb;&lsqb;cdecl&rsqb;&rsqb; {};
</code></pre>
<p>Leider spuckt mir GCC aus, dass er das Attribut eiskalt ignoriert.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2360631</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2360631</guid><dc:creator><![CDATA[Columbo]]></dc:creator><pubDate>Wed, 16 Oct 2013 08:25:24 GMT</pubDate></item><item><title><![CDATA[Reply to Lambda Aufruf Konvention on Wed, 16 Oct 2013 09:32:33 GMT]]></title><description><![CDATA[<p>Zeig mal den relevanten Code und nicht nur die Fehlermeldung. Oder besser noch: Ein vollständiges Minimalbeispiel.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2360651</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2360651</guid><dc:creator><![CDATA[krümelkacker]]></dc:creator><pubDate>Wed, 16 Oct 2013 09:32:33 GMT</pubDate></item><item><title><![CDATA[Reply to Lambda Aufruf Konvention on Wed, 16 Oct 2013 10:32:48 GMT]]></title><description><![CDATA[<pre><code>typedef void (__stdcall *Func)(int);
void test(Func){}
void __stdcall valid(int){}

int main(){
    test(valid);
    test([](int){});
}
</code></pre>
<pre><code>E:\...\test.cpp|7|error: cannot convert 'main()::&lt;lambda(int)&gt;' to 'Func {aka void (__attribute__((__stdcall__)) *)(int)}' for argument '1' to 'void test(Func)'|
</code></pre>
<p>Verwenden tue ich den mit Code::Blocks 12.11 mitgelieferten MinGW32 Compiler mit gcc version 4.7.1 (tdm-1).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2360676</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2360676</guid><dc:creator><![CDATA[Youka]]></dc:creator><pubDate>Wed, 16 Oct 2013 10:32:48 GMT</pubDate></item><item><title><![CDATA[Reply to Lambda Aufruf Konvention on Wed, 16 Oct 2013 10:51:35 GMT]]></title><description><![CDATA[<p>Aus einem mir unverständlichen Grund hat man entschieden, dass man den Typ eines Lambdas nicht hinschreiben können darf. Du versuchst in deiner Testfunktion den Typ eines Lambdas anzugeben und genau das soll nicht möglich sein (warum auch immer). Entweder du benutzt std::function und nimmst dynamische Speicherallokation in Kauf oder du machst ein Template draus. Dafür zu sorgen, dass ein Lambda kompatibel zu einem void (__stdcall *)(int) ist soll nicht möglich sein.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2360682</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2360682</guid><dc:creator><![CDATA[nwp3]]></dc:creator><pubDate>Wed, 16 Oct 2013 10:51:35 GMT</pubDate></item><item><title><![CDATA[Reply to Lambda Aufruf Konvention on Wed, 16 Oct 2013 10:54:52 GMT]]></title><description><![CDATA[<p>hmm, komisch ... hätte gedacht, dass der Compiler selbst so schlau wäre und sich anhand der impliziten Konvertierung von Lambda zu Funkionszeiger selbst die richtige Aufrufkonvention verwenden kann. Zumindest wurde in den Lambda-Proposals so etwas erwähnt. Man wolle auch C-APIs mit Lambdas bedienen können.</p>
<p>Also entweder verlangt der Standard von einem Compiler so eine Automatik, wobei der GCC 4.7 das dann offensichtlich noch nicht kann, <em>oder</em> Du erwartest zu viel an Magie.</p>
<p>Schau mal, ob du hier fündig wirst:<br />
<a href="http://open-std.org/JTC1/SC22/WG21/" rel="nofollow">http://open-std.org/JTC1/SC22/WG21/</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2360684</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2360684</guid><dc:creator><![CDATA[krümelkacker]]></dc:creator><pubDate>Wed, 16 Oct 2013 10:54:52 GMT</pubDate></item><item><title><![CDATA[Reply to Lambda Aufruf Konvention on Wed, 16 Oct 2013 11:03:06 GMT]]></title><description><![CDATA[<p>nwp3 schrieb:</p>
<blockquote>
<p>...</p>
</blockquote>
<p>Ein Lambda-Ausdruck mit leerer Capture-Clause ist implizit zu einem Funktionszeiger konvertierbar. Genau das wollte der OP hier machen. Ihm steht nur das <code>__stdcall</code> im Weg. Von <code>__stdcall</code> steht natürlich nichts im Standard, auch wenn da <code>std</code> drin vorkommt. Von daher kann man in diesem Fall auch nicht wirklich darüber sprechen, ob der Compiler sich hier konform verhält oder ob das wirklich nicht erlaubt ist. Es sieht für mich nach einer QoI (quality of implementation) Sache aus. Der GCC könnte dieses Auto-Magie-Feature unabhängig vom Standard einbauen. Ich weiß nur nicht, wie da die Chancen stehen. stdcall gibt's ja AFAIK auch nur in der Windows-Welt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2360685</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2360685</guid><dc:creator><![CDATA[krümelkacker]]></dc:creator><pubDate>Wed, 16 Oct 2013 11:03:06 GMT</pubDate></item><item><title><![CDATA[Reply to Lambda Aufruf Konvention on Wed, 16 Oct 2013 11:13:06 GMT]]></title><description><![CDATA[<p>krümelkacker schrieb:</p>
<blockquote>
<p>nwp3 schrieb:</p>
<blockquote>
<p>...</p>
</blockquote>
<p>Ein Lambda-Ausdruck mit leerer Capture-Clause ist implizit zu einem Funktionszeiger konvertierbar. Genau das wollte der OP hier machen. Ihm steht nur das <code>__stdcall</code> im Weg. Von <code>__stdcall</code> steht natürlich nichts im Standard, auch wenn da <code>std</code> drin vorkommt. Von daher kann man in diesem Fall auch nicht wirklich darüber sprechen, ob der Compiler sich hier konform verhält oder ob das wirklich nicht erlaubt ist. Es sieht für mich nach einer QoI (quality of implementation) Sache aus. Der GCC könnte dieses Auto-Magie-Feature unabhängig vom Standard einbauen. Ich weiß nur nicht, wie da die Chancen stehen. stdcall gibt's ja AFAIK auch nur in der Windows-Welt.</p>
</blockquote>
<p>Solche Magie würde ggf. zu Codeduplikation führen (die Konvertierung in eine Funktionszeiger muss ja nicht immer im Kontext des Lamdaausdrucks erfolgen).<br />
Auf die Schnelle finde ich <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2010/n3043.html" rel="nofollow">Proposal für lamda-Fpointer-Konvertierung</a> (angenommen) und<br />
<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1557" rel="nofollow">Defekt #1557</a> wobei die vorgeschlagene Lösung eher nicht darauf abziehlt, polymorphe Aufrufkonventionen zu erlauben (wobei Linkage ja nur indirekt etwas mit der Aufrufkonvention (=ABI-Feature) zu tun hat).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2360687</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2360687</guid><dc:creator><![CDATA[camper]]></dc:creator><pubDate>Wed, 16 Oct 2013 11:13:06 GMT</pubDate></item><item><title><![CDATA[Reply to Lambda Aufruf Konvention on Wed, 16 Oct 2013 12:36:26 GMT]]></title><description><![CDATA[<p>Youka schrieb:</p>
<blockquote>
<p>Ich muss z.B. eine Funktion mit __stdcall übergeben, Lambdas werden allerdings immer mit __cdecl erstellt.</p>
</blockquote>
<p>Ugh, gibt es unter Windows immer noch keine einheitliche Calling Convention? Dachte dieses DOS-Relikt hätte man längst beseitigt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2360711</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2360711</guid><dc:creator><![CDATA[bärbel!]]></dc:creator><pubDate>Wed, 16 Oct 2013 12:36:26 GMT</pubDate></item><item><title><![CDATA[Reply to Lambda Aufruf Konvention on Wed, 16 Oct 2013 12:41:51 GMT]]></title><description><![CDATA[<p>Calling Conventions sind kein DOS-Relikt. (Die Behauptung macht nichtmal Sinn. Man könnte behaupten, dass Windows mit stdcall arbeitet ist ein &quot;DOS-Relikt&quot; (ist es nicht, weil in der DOS-API völlig andere Calling Conventions üblich waren. Das ist also höchstens ein Windows-Relikt...))</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2360713</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2360713</guid><dc:creator><![CDATA[Bashar]]></dc:creator><pubDate>Wed, 16 Oct 2013 12:41:51 GMT</pubDate></item><item><title><![CDATA[Reply to Lambda Aufruf Konvention on Wed, 16 Oct 2013 12:46:57 GMT]]></title><description><![CDATA[<p>Das gibt's auch auf allen anderen Plattformen. Nur machen unter *NIX alle cdecl, so dass man da in C-Code nichts von merkt. Wenn du unter Linux Pascal-Code schreibst (ich weiß, macht niemand mehr, und das ist auch besser so), musst du Funktionen aus C-Bibliotheken mit cdecl kennzeichnen, denn da hat man per default üblicherweise stdcall.</p>
<p>Das wird man auch nicht mehr los, weil Kompatibilität.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2360716</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2360716</guid><dc:creator><![CDATA[seldon]]></dc:creator><pubDate>Wed, 16 Oct 2013 12:46:57 GMT</pubDate></item><item><title><![CDATA[Reply to Lambda Aufruf Konvention on Wed, 16 Oct 2013 13:53:44 GMT]]></title><description><![CDATA[<p>Die AMD64 ABI von *NIX ist kein cdecl mehr und unterscheidet sich auch bei Systemaufrufen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2360722</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2360722</guid><dc:creator><![CDATA[TNA]]></dc:creator><pubDate>Wed, 16 Oct 2013 13:53:44 GMT</pubDate></item><item><title><![CDATA[Reply to Lambda Aufruf Konvention on Thu, 17 Oct 2013 04:05:09 GMT]]></title><description><![CDATA[<p>Danke für eure Antworten.<br />
Dies bestätigt leider meine weiteren Funde im Web, schade <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /> Hoffe ich mal, das wird in späteren Compilern unterstützt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2360814</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2360814</guid><dc:creator><![CDATA[Youka]]></dc:creator><pubDate>Thu, 17 Oct 2013 04:05:09 GMT</pubDate></item></channel></rss>