From: "Berger, Daniel" Date: 2005-07-26T04:18:37+09:00 Subject: Re: Ruby extensions on 64 bit linux > -----Original Message----- > From: Joe Van Dyk [mailto:joevandyk@gmail.com] > Sent: Monday, July 25, 2005 12:24 PM > To: ruby-talk ML > Subject: Ruby extensions on 64 bit linux > > > http://www.ruby-talk.org/cgi-bin/scat.rb/ruby/ruby-talk/149446 > makes me wonder, when writing C extensions, are there > anything I should be watching out for when intending the code > to be run on a 64 bit OS? > > Thanks, > Joe * Don't assume a pointer and an int are the same size * Don't make assumptions about the relative size of variable types * Be wary of sign extension problems * Use pointer arithmetic rather than address arithmetic * Never cast malloc * Explicitly include header files (-Wall will warn you about implicit declarations) * Watch out for data truncation, e.g. passing a size_t to something that expects an int. * Pack (align) your data structures as tightly as possible * Watch out for data loss in constant expressions * Use %p in your (s)printf's as appropriate * Use #ifdef _LP64 as needed (or is that Solaris only?) Regards, Dan