Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enchanced cbindgen - zig #1

Closed
kassane opened this issue May 1, 2022 · 1 comment
Closed

Enchanced cbindgen - zig #1

kassane opened this issue May 1, 2022 · 1 comment
Labels
bug Something isn't working enhancement New feature or request good first issue Good for newcomers

Comments

@kassane
Copy link
Owner

kassane commented May 1, 2022

This experiment refers to the development of the zig-bindgen branch.
Below you will find errors during the translation that should be corrected.

Expected

generated/binding.zig: [ FFI Work]

const std = @import("std");

pub const Doggo = extern struct {
    age: i32,
    name: [*:0]const u8,
};

pub extern fn call_name(ptr: ?*Doggo, name: [*:0]const u8) anyopaque;
pub extern fn is_whitespace(byte: u8) bool;
pub extern fn mul(value1: usize, value2: usize) usize;
pub extern fn add(value1: usize, value2: usize) usize;

CBindgen

Generated:

const std = @import("std");

pub const Doggo = extern struct {
  age: i32,
   _name: ?fn, // type error
};

// missing pub keyword to public functions
extern fn call_name( _ptr: ?fn, const  constname: ?fn) anyopaque; // flags type error
extern fn is_whitespace(byte: u8) bool;
extern fn mul(value1: usize, value2: usize) usize;
extern fn add(value1: usize, value2: usize) usize;
@kassane kassane added bug Something isn't working enhancement New feature or request labels May 1, 2022
@kassane
Copy link
Owner Author

kassane commented May 1, 2022

Fixed!

@kassane kassane closed this as completed May 1, 2022
@kassane kassane added the good first issue Good for newcomers label May 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant