Skip to content

Instantly share code, notes, and snippets.

@Diltsman
Created July 28, 2019 05:32
Show Gist options
  • Save Diltsman/b7a18134a7c95e771e4fa307411a7f9a to your computer and use it in GitHub Desktop.
Save Diltsman/b7a18134a7c95e771e4fa307411a7f9a to your computer and use it in GitHub Desktop.
wrapping function in function
fn interupt_handler(comptime func: fn () void) nakedcc fn () void {
return nakedcc fn () void {
func();
};
}
@fengb
Copy link

fengb commented Jul 28, 2019

Does this work?

fn interupt_handler(comptime func: fn () void) nakedcc fn () void {
    return struct {
        nakedcc fn f() void {
            func();
        };
    }.f;
}

@Diltsman
Copy link
Author

It didn't like the semicolon after the function. Removing the semicolon gave this error:
error: expected type 'type', found 'nakedcc fn() void'

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