Re: gpointer question
- From: Archit Baweja <bighead users sourceforge net>
- To: Jim Parker <hopeye cfl rr com>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: gpointer question
- Date: 16 Aug 2003 12:05:23 +0530
As a good programming practice, if you keep a gpointer (void *) to the struct
in your typModel, should also have a enumeration which is says what kind of
strut is stored in the "modeldata" pointer. This is because C doesn't really
have that kind of type checking when you are converting back from "void */gpointer" back to the structure.
Some changes I suggest.
+ enum ModelDataType {
+ TYPE_SHIP,
+ TYPE_FOO,
+ TYPE_BAR
+ };
typedef struct {
int model_id;
int active;
int units;
typGeometry geodata;
+ ModelDataType modeltype;
gpointer modeldata;
} typModel;
typdef struct {
float length;
float lwl;
float beam;
float draft;
float depth;
} typShip;
Just a thought
Archit Baweja
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]