Closed erdemyerebasmaz closed 2 days ago
Hi! Thanks for opening your first issue here! :smile:
As mentioned in the discussion, feel free to fix it, alternatively I will work on it in the next batch (hopefully within a week) :)
EDIT: Sorry for the latency, but I am really busy recently, and this is not a critical bug and has workarounds, thus I hope to work on it a bit later.
I see: It seems that cbindgen considers c++ keywords and add postfix when detects one. https://github.com/mozilla/cbindgen/blob/ca78140c01518a655355f84da1f3872939123b66/src/bindgen/reserved.rs#L8
A fix may be, let frb understand this (e.g. when reading/writing the field, use the name template_
instead of template
).
Another workaround in order to use this name is that, remove full_dep: true
in your frb configuration, then the codec will not use cbindgen and thus no this issue.
Describe the bug
Rust structs field that are the same name with C++ Reserved Words, which are not shared with Rust or Dart, are now generated with an underscore suffix on the wire object with frb v2.
Generator completes without issues and this only becomes apparent upon using the bindings.
Related discussion:
Steps to reproduce
Create a struct with a field that uses C++ keywords that are not shared with Rust or Dart,
friend
,goto
,template
etc., they can be of any type and generate bindings for it.Logs
logs.txt (8K lines, a bit laggy)
Expected behavior
Keywords that are not reserved by Rust or Dart should generate as is.
Generated binding code
For a struct that has a field named
template
OS
macOS Sonoma 14.4.1
Version of
flutter_rust_bridge_codegen
2.0.0-dev.32
Flutter info
Version of
clang++
Additional context
Error received on building the app that uses bindings: