Re: Style convention question
- From: Sven Neumann <sven gimp org>
- To: Derek Simkowiak <dereks realloc net>
- Cc: gtk-devel-list gnome org
- Subject: Re: Style convention question
- Date: 09 Mar 2001 17:35:44 +0100
Hi,
Derek Simkowiak <dereks realloc net> writes:
> Why does Glib do this:
>
> typedef struct _GFoo GFoo;
> struct _GFoo {
> /* [...] */
> };
>
> ...instead of the more compact
>
> typedef struct {
> /* [...] */
> } GFoo;
this allows you to put the typedef into a different place than the
structure declaration. For apps it makes sense to put all typedefs
into one header that is included by all C files so the types are
known everywhere, while only a few C files need access to the structs
members and need to include the respective header file. Often it is
also desirable to make the structure declaration private by moving
it into the C file. The rest of the app then can use the type, but
needs to access it thru provided accessor functions. GLib/GTK+ does
not make heavy use of this possibilities, but IMO it's a good habit
to stick with that style for all typedefs.
Salut, Sven
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]