From: matz@... (Yukihiro Matsumoto) Date: 2003-12-09T17:00:57+09:00 Subject: Re: RCR - 'struct flock*' wrapper for rb_io_fcntl Hi, In message "Re: RCR - 'struct flock*' wrapper for rb_io_fcntl" on 03/12/09, "Ara.T.Howard" writes: |> You can use pack/unpack for the purpose. |> |> require 'fcntl' # import constants, perhaps this replaces IO#fcntl... |> |> f = open('/tmp/foobar', 'w') |> flock = [Fcntl::F_RDLCK, 0, 0, 0, 0].pack("ssqqi") | |is this guaranteed to work: | | are the offsets always the same as a struct flock* as the compiler lays them | out? | |if so, i am personally o.k with this. (thanks for the pointer!) It works. Perl people do similar things a lot. But it's not portable. |> But still I would not deny your proposal for the sake of readability |> and portability. Maybe there can be functions that work similar to |> pack_sockaddr_*() / unpack_sockaddr_*() in the socket extension. |> pack_flock() or something. | |yes that sounds good if anwser to above is 'yes' Yes, and preparing pack/unpack function, they can be portable. matz.