<?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[memberfunktion als callback fuer eine c funktion]]></title><description><![CDATA[<p>Hallo zusammen,</p>
<p>gibt es eine moeglichkeit einer c funktion einen callback zu deffinieren der an eine memberfunktion geht?</p>
<p>(Compiler: gcc/linux)</p>
<p>Mal ein kleines Beispiel dazu:</p>
<pre><code>class Eins {
    public:
       Eins();
       void machwas();
       int mycallback(char *);
    protected:
       int fd;
}

Eins::Eins() 
{
    fd = open(...);
    // noch mehr code
}

void Eins::machwas()
{
    c_funktion_die_einen_callback_benoetigt(&amp;Eins::mycallback);
}

int Eins::mycallback(char *data)
{
    write(fd, ...)
}
</code></pre>
<p>so wie ich das in &quot;Eins::machwas()&quot; geschrieben habe funktioniert es leider nicht...</p>
<p>Jemand eine Idee?</p>
<p>Danke und gruesse</p>
<p>kali</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/218260/memberfunktion-als-callback-fuer-eine-c-funktion</link><generator>RSS for Node</generator><lastBuildDate>Fri, 09 Oct 2026 12:32:56 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/218260.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 18 Jul 2008 08:54:58 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to memberfunktion als callback fuer eine c funktion on Fri, 18 Jul 2008 08:54:58 GMT]]></title><description><![CDATA[<p>Hallo zusammen,</p>
<p>gibt es eine moeglichkeit einer c funktion einen callback zu deffinieren der an eine memberfunktion geht?</p>
<p>(Compiler: gcc/linux)</p>
<p>Mal ein kleines Beispiel dazu:</p>
<pre><code>class Eins {
    public:
       Eins();
       void machwas();
       int mycallback(char *);
    protected:
       int fd;
}

Eins::Eins() 
{
    fd = open(...);
    // noch mehr code
}

void Eins::machwas()
{
    c_funktion_die_einen_callback_benoetigt(&amp;Eins::mycallback);
}

int Eins::mycallback(char *data)
{
    write(fd, ...)
}
</code></pre>
<p>so wie ich das in &quot;Eins::machwas()&quot; geschrieben habe funktioniert es leider nicht...</p>
<p>Jemand eine Idee?</p>
<p>Danke und gruesse</p>
<p>kali</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1549221</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1549221</guid><dc:creator><![CDATA[kali]]></dc:creator><pubDate>Fri, 18 Jul 2008 08:54:58 GMT</pubDate></item><item><title><![CDATA[Reply to memberfunktion als callback fuer eine c funktion on Fri, 18 Jul 2008 09:20:43 GMT]]></title><description><![CDATA[<p>Wie wäre es mit der Benutzung einer Suchmaschine ?</p>
<p><a href="http://www.newty.de/fpt/index.html" rel="nofollow">http://www.newty.de/fpt/index.html</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1549239</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1549239</guid><dc:creator><![CDATA[I_AM_Legend]]></dc:creator><pubDate>Fri, 18 Jul 2008 09:20:43 GMT</pubDate></item><item><title><![CDATA[Reply to memberfunktion als callback fuer eine c funktion on Fri, 18 Jul 2008 09:23:34 GMT]]></title><description><![CDATA[<p>Danke schoen, ich hab schon ne weile gesucht gehabt aber bin nie ueber ein ordendliches Ergebniss gestollpert. aber ich werde mir die seite mal anschauen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1549242</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1549242</guid><dc:creator><![CDATA[kali]]></dc:creator><pubDate>Fri, 18 Jul 2008 09:23:34 GMT</pubDate></item><item><title><![CDATA[Reply to memberfunktion als callback fuer eine c funktion on Fri, 18 Jul 2008 11:05:52 GMT]]></title><description><![CDATA[<p>Du kannst ein &quot;Trampolin&quot; basteln (siehe &quot;trampoline function&quot; aka. &quot;thunk&quot;), d.h. eine free function, die dann an eine Memberfunktion &quot;weiterleitet&quot;.</p>
<p>Dazu muss entweder die Memberfunktion statisch sein, oder das Callback muss einen Userdata/Context/... Pointer haben für den du beim Setzen einen Wert übergeben kannst. (Es muss kein Pointer sein, aber halt irgendwas wo du mit z.B. reinterpret_cast nen Zeiger reinbekommst und verlustfrei wieder zurück, z.B. ein ULONG_PTR oder sowas)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1549305</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1549305</guid><dc:creator><![CDATA[hustbaer]]></dc:creator><pubDate>Fri, 18 Jul 2008 11:05:52 GMT</pubDate></item></channel></rss>