Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Unable to attach functions ending in ? or ! #971

@eizengan

Description

@eizengan

FFI is unable to attach functions when instructed to use method names ending in ? or ! - both of which are common Ruby-isms. The following illustrates the problem:

require "ffi"
# => true
module Foo
  extend FFI::Library
  ffi_lib 'c'

  attach_function :malloc!, :malloc, [:size_t], :pointer
end
# Traceback (most recent call last):
#         ...
#         3: from (irb):6:in `<module:Foo>'
#         2: from /Users/nate.eizenga/.asdf/installs/ruby/2.6.10/lib/ruby/gems/2.6.0/gems/ffi-1.15.5/lib/ffi/library.rb:275:in `attach_function'
#         1: from /Users/nate.eizenga/.asdf/installs/ruby/2.6.10/lib/ruby/gems/2.6.0/gems/ffi-1.15.5/lib/ffi/library.rb:275:in `attach'
# NameError (wrong class variable name @@malloc!)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions