Re: G_GNUC_CONST with _get_type() usage



Hi,

Tim Janik <timj gtk org> writes:

> _get_type() functions do have side effects, that of registering
> a type upon first invocation.
> 
> i'm not going back through the code to get rid of all these,
> though that would be the Right Thing to do. as it stands now,
> people will just have to be aware that code like:
> 
> /* gtk_vscale_get_type() hasn't been called yet */
> gtk_vscale_get_type ();
> printf ("vscale type_id=%u\n", g_type_from_name ("GtkVScale"));
> 
> will not work under gcc, because it legitemately optimizes
> the function call away.

over here at convergence, we use some code that relies heavily 
on the fact that types get registered to the GType system before 
the objects are actually created. The code I'm speaking of looks 
exactly as you describe it here. Since at the moment we only use 
it on custom objects, we are not affected by this problem, but I 
can imagine that similar code will be written that makes use of 
GtkObjects. For that reason, I think we should go through the 
hassle and remove the G_GNUC_CONST from all get_type() functions. 
I'd also volunteer to do the job...


Salut, Sven




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