flat assembler
Message board for the users of flat assembler.

Index > High Level Languages > Dealing with C Structures with bit-field members

Author
Thread Post new topic Reply to topic
silkodyssey



Joined: 02 Oct 2003
Posts: 198
Location: St.Vincent & the Grenadines
silkodyssey 29 Apr 2006, 15:10
I would like to translate some c headers files but I am unsure of how to approach the members variables defined with the size of a certain number of bits. For example

Code:
 
struct _GtkWindow
{
  GtkBin bin;

  gchar *title;
  gchar *wmclass_name;
  gchar *wmclass_class;
  gchar *wm_role;

  GtkWidget *focus_widget;
  GtkWidget *default_widget;
  GtkWindow *transient_parent;
  GtkWindowGeometryInfo *geometry_info;
  GdkWindow *frame;
  GtkWindowGroup *group;

  guint16 configure_request_count;
  guint allow_shrink : 1;
  guint allow_grow : 1;
  guint configure_notify_received : 1;
  /* The following flags are initially TRUE (before a window is mapped).
   * They cause us to compute a configure request that involves
   * default-only parameters. Once mapped, we set them to FALSE.
   * Then we set them to TRUE again on unmap (for position)
   * and on unrealize (for size).
   */
  guint need_default_position : 1;
  guint need_default_size : 1;
  guint position : 3;
  guint type : 4; /* GtkWindowType */ 
  guint has_user_ref_count : 1;
  guint has_focus : 1;

  guint modal : 1;
  guint destroy_with_parent : 1;
  
  guint has_frame : 1;

  /* gtk_window_iconify() called before realization */
  guint iconify_initially : 1;
  guint stick_initially : 1;
  guint maximize_initially : 1;
  guint decorated : 1;
  
  guint type_hint : 3; /* GdkWindowTypeHint */ 
  guint gravity : 5; /* GdkGravity */

  guint is_active : 1;
  guint has_toplevel_focus : 1;
  
  guint frame_left;
  guint frame_top;
  guint frame_right;
  guint frame_bottom;

  guint keys_changed_handler;
  
  GdkModifierType mnemonic_modifier;
  GdkScreen      *screen;
};
    


What I would like is a way to declare the fields so that they can be accessed transparently as would be possible in C. At the moment they way I intend to solve the problem is just count the total number of bits for each member and declare a generic variable big enough for the fields. This way the if I follow the gtk reference and use a structure member that is a bit field, fasm will alert me of the error and I could verify whats going on according to how the structure was translated. This is what I have come up with so far. Is it an ok solution or can it be done better?

_________________
silkodyssey
Post 29 Apr 2006, 15:10
View user's profile Send private message MSN Messenger Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.