Re: G_GNUC_CONST with _get_type() usage
- From: Havoc Pennington <hp redhat com>
- To: Sven Neumann <sven gimp org>
- Cc: Tim Janik <timj gtk org>, Gtk+ Developers <gtk-devel-list gnome org>
- Subject: Re: G_GNUC_CONST with _get_type() usage
- Date: 11 May 2001 09:23:52 -0400
Sven Neumann <sven gimp org> writes:
>
> 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...
>
There is a trivial workaround, which is something like:
volatile GType dummy = foo_get_type ();
This is what I used when I encountered this problem a while back.
Basically you just have to use the return value in some way that the
compiler can't prove is useless.
I think these functions are conceptually const, and the G_GNUC_CONST
probably does reduce code size by avoiding function calls. (Though I'd
want to see measurements before getting too vehement about it.)
Havoc
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]