Skip to content

Comments

Support attributes#13

Open
davispuh wants to merge 1 commit intoMVV90:mainfrom
davispuh:attrs
Open

Support attributes#13
davispuh wants to merge 1 commit intoMVV90:mainfrom
davispuh:attrs

Conversation

@davispuh
Copy link

@davispuh davispuh commented Feb 2, 2026

Currently ruby_ffi_generator doesn't support attributes, so code like this:

struct a {
  int b;
} __attribute__((aligned(4)));

Fails with:

lib/ffi_generator/generators/from_c_generator/generator.rb:322:in 'FFIGenerate::Generator#read_struct_or_union_declaration': unhandled exception
        from lib/ffi_generator/generators/from_c_generator/generator.rb:205:in 'FFIGenerate::Generator#read_declaration'
        from lib/ffi_generator/generators/from_c_generator/generator.rb:192:in 'block in FFIGenerate::Generator#declarations'
        from lib/ffi_generator/generators/from_c_generator/generator.rb:184:in 'Array#each'
        from lib/ffi_generator/generators/from_c_generator/generator.rb:184:in 'Enumerable#each_with_index'
        from lib/ffi_generator/generators/from_c_generator/generator.rb:184:in 'FFIGenerate::Generator#declarations'

This PR fixes that by adding attribute support.
Note that actually passing alignment requirements to FFI is not implemented and it will create regular struct like this

class A < FFI::Struct
  layout :b , :int
end

Copilot AI review requested due to automatic review settings February 2, 2026 19:38
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant