Skip to content

Instantly share code, notes, and snippets.

@brixen
Created August 28, 2009 19:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brixen/177154 to your computer and use it in GitHub Desktop.
Save brixen/177154 to your computer and use it in GitHub Desktop.
11:57 nicksieger >> compile time to get the field names, yes
11:57 evan >> well sort of
11:57 evan >> i'd like that to work
11:57 nicksieger >> assuming they don't change betw. platforms
11:58 evan >> but it doesn't work all the time
11:58 wycats >> evan: in what case doesn't it work?
11:58 evan >> some platforms put fields of different names in structs
11:58 brixen >> yep
11:58 wycats >> wot
11:58 evan >> sounds stupid, but it happens
11:58 wycats >> like what?
11:58 evan >> well, stat is a good example
11:58 nicksieger >> struct MyWackyStruct { int a; \n #ifdef MACOSX int b; #endif } etc
11:58 brixen >> wycats: you should just make the gem have a build step on install
11:58 evan >> fields appear and disappear from stat
11:58 brixen >> dirent too iirc
11:58 evan >> probably
11:58 wycats >> brixen: gccxml isn't always available
11:58 nicksieger >> brixen: right
11:59 wycats >> maybe it could be installed with libffi?
11:59 evan >> gccxml is a huge depedency
11:59 evan >> HUGE.
11:59 evan >> better to use gccxml at dev time
11:59 evan >> to write an initial version of the FFI::Struct layout
11:59 evan >> then you prune it
11:59 brixen >> wycats: basic point is, this is platform dependent. you can wriggle and squirm,
but that's not going away
11:59 evan >> to remove fields you don't want
11:59 evan >> or you know won't be available elsewhere
12:00 brixen >> that's why our struct gen is that way
12:00 brixen >> you say which fields you want sizes and offsets for
12:00 ::: wycats1 [n=Adium@rrcs-67-79-18-46.sw.biz.rr.com] has joined #eyimps
12:00 nicksieger >> wycats: http://cast.rubyforge.org/
http://github.com/jameskilton/rbgccxml/tree/master
12:00 wycats1 >> that's why I want it to be compile time
12:01 wycats1 >> it uses libxml-ruby :(
12:01 evan >> gccxml usage should be dev time only
12:01 evan >> and it should simply assist in writing your FFI::Struct layout
12:01 evan >> like an IDE giving you an initial version
12:01 brixen >> like a template generator
12:01 wycats1 >> evan: you just said that wouldn't work
12:01 wycats1 >> because of the different platform ifdef problem
12:02 brixen >> it won't work without some manual intervention in some cases
12:03 evan >> wycats1: you must have missed some things
12:03 evan >> with your reconnect.
12:03 wycats1 >> yeah
12:03 wycats1 >> plz repeat?
12:03 brixen >> wycats1: sec..
12:03 evan >> gccxml could be a nice way to generate a first cut at an FFI::Struct layout
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment