Subject: Re: [ruby-ffi] using C macros |
From: Shawn Anderson |
Date: 5/20/10 8:33 PM |
To: ruby-ffi@googlegroups.com |
The same explanation also holds for static inline functions, which are more frustrating since they are often less trivial than macros. For non-trivial code, creating a support library in C and linking it with FFI has been a good approach for me.Best,JeremyOn Thu, May 20, 2010 at 4:57 PM, Wayne Meissner <wmeissner@gmail.com> wrote:
No, C macros are not present in the library as code, since they are
handled by the C pre-processor.
You could just implement ruby versions of those macros (they should be
pretty simple).
On 21 May 2010 01:22, mixtli <ronmcclain75@gmail.com> wrote:
> Is it possible to access macros such as FD_SET and FD_ZERO? I'm
> trying to wrap net-snmp, specifically the snmp_select_info function
> which is called in C like so:
>
> int fds = 0, block = 1;
> fd_set fdset;
> struct timeval timeout;
> FD_ZERO(&fdset);
> snmp_select_info(&fds, &fdset, &timeout, &block);
> fds = select(fds, &fdset, 0,0, block ? 0 : &timeout);
> if(fds) { snmp_read(&fdset); } else { snmp_timeout(); }
>
>
> I've been trying to do it with ffi-inliner, but haven't had much
> luck. Any pointers would be appreciated.
>
>