<?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[Verständnisproblem g_signal_connect]]></title><description><![CDATA[<pre><code class="language-cpp">/**
 * G_CALLBACK:
 * @f: a function pointer.
 * 
 * Cast a function pointer to a #GCallback.
 */
#define	G_CALLBACK(f)			 ((GCallback) (f))
</code></pre>
<pre><code class="language-cpp">/**
 * GCallback:
 * 
 * The type used for callback functions in structure definitions and function 
 * signatures. This doesn't mean that all callback functions must take no 
 * parameters and return void. The required signature of a callback function 
 * is determined by the context in which is used (e.g. the signal to which it 
 * is connected). Use G_CALLBACK() to cast the callback function to a #GCallback. 
 */
typedef void  (*GCallback)              (void);
</code></pre>
<pre><code class="language-cpp">/**
 * g_signal_connect:
 * @instance: the instance to connect to.
 * @detailed_signal: a string of the form &quot;signal-name::detail&quot;.
 * @c_handler: the #GCallback to connect.
 * @data: data to pass to @c_handler calls.
 * 
 * Connects a #GCallback function to a signal for a particular object.
 * 
 * The handler will be called before the default handler of the signal.
 * 
 * Returns: the handler id
 */
#define g_signal_connect(instance, detailed_signal, c_handler, data) \
    g_signal_connect_data ((instance), (detailed_signal), (c_handler), (data), NULL, (GConnectFlags) 0)
</code></pre>
<p>Usage:</p>
<pre><code class="language-cpp">static gboolean
on_rect_button_press (void* rect, void* obj2, void* data, char* something,void* blue )
{
  /* bla bla */
  return true ;
}
</code></pre>
<pre><code class="language-cpp">g_signal_connect (rect, &quot;button-press-event&quot;,
    G_CALLBACK (on_rect_button_press), einvoidstern); // Woher weiß die Funktion 'g_signal_connect', wo sie 'einvoidstern' hingeben soll?
</code></pre>
<p>Ich verstehe es grundsaetzlich nicht, wie das ueberhaupt funktionieren soll. Denn die Funktion wird ja in ein void (*f) (void) gecastet. <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="😞"
    /></p>
<p>Kann mir jemand das erklären?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/263404/verständnisproblem-g_signal_connect</link><generator>RSS for Node</generator><lastBuildDate>Sat, 05 Sep 2026 18:23:58 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/263404.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 20 Mar 2010 12:09:56 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Verständnisproblem g_signal_connect on Sat, 20 Mar 2010 12:09:56 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">/**
 * G_CALLBACK:
 * @f: a function pointer.
 * 
 * Cast a function pointer to a #GCallback.
 */
#define	G_CALLBACK(f)			 ((GCallback) (f))
</code></pre>
<pre><code class="language-cpp">/**
 * GCallback:
 * 
 * The type used for callback functions in structure definitions and function 
 * signatures. This doesn't mean that all callback functions must take no 
 * parameters and return void. The required signature of a callback function 
 * is determined by the context in which is used (e.g. the signal to which it 
 * is connected). Use G_CALLBACK() to cast the callback function to a #GCallback. 
 */
typedef void  (*GCallback)              (void);
</code></pre>
<pre><code class="language-cpp">/**
 * g_signal_connect:
 * @instance: the instance to connect to.
 * @detailed_signal: a string of the form &quot;signal-name::detail&quot;.
 * @c_handler: the #GCallback to connect.
 * @data: data to pass to @c_handler calls.
 * 
 * Connects a #GCallback function to a signal for a particular object.
 * 
 * The handler will be called before the default handler of the signal.
 * 
 * Returns: the handler id
 */
#define g_signal_connect(instance, detailed_signal, c_handler, data) \
    g_signal_connect_data ((instance), (detailed_signal), (c_handler), (data), NULL, (GConnectFlags) 0)
</code></pre>
<p>Usage:</p>
<pre><code class="language-cpp">static gboolean
on_rect_button_press (void* rect, void* obj2, void* data, char* something,void* blue )
{
  /* bla bla */
  return true ;
}
</code></pre>
<pre><code class="language-cpp">g_signal_connect (rect, &quot;button-press-event&quot;,
    G_CALLBACK (on_rect_button_press), einvoidstern); // Woher weiß die Funktion 'g_signal_connect', wo sie 'einvoidstern' hingeben soll?
</code></pre>
<p>Ich verstehe es grundsaetzlich nicht, wie das ueberhaupt funktionieren soll. Denn die Funktion wird ja in ein void (*f) (void) gecastet. <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="😞"
    /></p>
<p>Kann mir jemand das erklären?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1871592</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1871592</guid><dc:creator><![CDATA[grübel grübel]]></dc:creator><pubDate>Sat, 20 Mar 2010 12:09:56 GMT</pubDate></item><item><title><![CDATA[Reply to Verständnisproblem g_signal_connect on Tue, 23 Mar 2010 07:43:22 GMT]]></title><description><![CDATA[<p>grübel grübel schrieb:</p>
<blockquote>
<p>Ich verstehe es grundsaetzlich nicht, wie das ueberhaupt funktionieren soll. Denn die Funktion wird ja in ein void (*f) (void) gecastet. <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="😞"
    /></p>
</blockquote>
<p>Da wird der Funktionspointer wohl, <em>bevor</em> er aufgerufen wird, nochmal umgecastet.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1872800</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1872800</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Tue, 23 Mar 2010 07:43:22 GMT</pubDate></item></channel></rss>