g_module_symbol signature



Hello,

g_module_symbol last argument is of type gpointer *, i.e. something like
void **, and this is used to represent a function pointer. I may be
wrong, but I think (according to C99 standard) that a void pointer, and
a function pointer are different.

This leads to the famous "dereferencing type-punned pointer will break
strict-aliasing rules" warning when you use -fstrict-aliasing gcc option
:

typedef void (* FunctionType)(void);
FunctionType f;
g_module_symbol (module, "function_name", (gpointer *)&f); // here


(http://www.ethereal.com/lists/ethereal-dev/200309/msg00343.html has a
good explanation of what this warning is about)


I think "gpointer" would be a more correct type for the last argument
(simply a pointer on a pointer of function). Another solution is to use
a pointer on a void(void) function.

What do you think ? Should I file a bug ?

Nicolas





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]