Module: FFI::Library

Included in:
DRY::ErrnoHelper, DRY::NetEndian
Defined in:
lib/ffi/dry.rb

Instance Method Summary collapse

Instance Method Details

#attach_optional_function(*args) ⇒ Object

Helper method for attaching optional functions which may not be present. Just catches and ignores any FFI::NotFoundError exceptions.



13
14
15
16
17
18
19
20
# File 'lib/ffi/dry.rb', line 13

def attach_optional_function(*args)
  begin
    attach_function(*args)
  rescue FFI::NotFoundError => e
    warn "WARNING: #{e.to_s}" if $DEBUG
    nil
  end
end