-
Notifications
You must be signed in to change notification settings - Fork 8
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
Lambda mangling test #5
Comments
C++11/14Typedinput int square = [](int num) {
return num * num;
}; output info: binding `cxx.h`
info: transpiled 51/51 (100.00 %)
info: formating `x86_64/linux/gnu/cxx.zig` // auto generated by c2z
const std = @import("std");
//const cpp = @import("cpp");
extern var square: c_int;
pub inline fn square() *c_int {
return □
} deductedinput auto square = [](auto num) {
return num * num;
}; output info: binding `cxx.h`
error: unknow type `(lambda at cxx.h:2:15)`, falling back to `*anyopaque`
info: transpiled 56/56 (100.00 %)
info: formating `x86_64/linux/gnu/cxx.zig` // auto generated by c2z
const std = @import("std");
//const cpp = @import("cpp");
extern var square: *anyopaque;
pub inline fn square() **anyopaque {
return □
} error: redeclaration of 'square' |
I don't think lambda is a feature that I wan't to support, but is nice to keep in mind |
Just out of curiosity is there any library that shows a real use example of this? |
No! I don't know of any libraries that have this requirement. It is probably a very recent topic to discuss. clang tests: |
Another test int foo(){
return [](){return 6;}();
} Output: // auto generated by c2z
const std = @import("std");
//const cpp = @import("cpp");
pub fn foo() c_int {
return;
} Suggestion: fn unammed() c_int { return 6; }
pub fn foo() c_int { return unammed(); } or try zig callback Reference: |
Some lambda test - C++20: https://godbolt.org/z/Gq1h7Ezn9
Lambda 1
input
output
Lambda 2
input
output
References
The text was updated successfully, but these errors were encountered: