hi;

On 23 August 2014 11:18, Iñigo Martínez <inigomarti...@gmail.com> wrote:
> Yes, it works, but i doesn't look like the best approach:
>
> warning: ISO C forbids passing argument 3 of 'g_hash_table_insert'
> between function pointer and 'void *' [-Wpedantic]

drop `-Wpedantic`: it doesn't serve any practical purposes. instead,
identify a set of warnings that you care about, and use them.

in this particular case, we're talking about undefined behaviour that
every compiler that is not a university student project, or an arcane
compiler for a niche architecture, supports anyway.

in practice, everything that GLib supports, will also support this construct.

ciao,
 Emmanuele.

> 2014-08-22 18:29 GMT+02:00 Emmanuele Bassi <eba...@gmail.com>:
>> hi;
>>
>> On 22 August 2014 17:10, Iñigo Martínez <inigomarti...@gmail.com> wrote:
>>
>>> I am trying to figure out the best way to use function pointers as
>>> values in a GHashTable. My idea is to call different functions based
>>> on different keys (strings).
>>>
>>> Looking at the API, this looks impossible, as the values are gpointers
>>> and not function pointers.
>>
>> gpointer is just a typedef to void*, which is perfectly capable of
>> holding a function pointer.
>>
>>> I'm thinking to wrap the function call in a structure, and hold its
>>> pointer in the table.
>>>
>>> Has anyone ever tried something similar ?
>>
>> yes, and it works fine.
>>
>> ciao,
>>  Emmanuele.
>>
>> --
>> http://www.bassi.io
>> [@] ebassi [@gmail.com]



-- 
http://www.bassi.io
[@] ebassi [@gmail.com]
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Reply via email to