You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
C++ does use namespaces which help avoiding name pollution. However in C the usual way to do this is just using the "namespaces" as prefixes of the names. For functions and other ABI exports this cannot really be changed unless the export name is changed as well. However for types (typedefs, enums, structs) this can be prefixed by cbindgen so that the actual items do not need to have these extra prefixes in the Rust code. I tried looking at the code and added an option for it, but then I got lost because there was no way to extract the path to the item. An example could be something like:
where asdf is the name of the crate. This would make all the types and values uniquely identifiable the same way it is usually done in C libraries. That would help us with libraries that should be usable from C code and also porting some existing C code to Rust for which we currently need to write the header files manually.
This does look similar to #7 although I do not see this particular thing mentioned there. If that is supposed to be a part of it, then feel free to close this.
Also it looks like #214 keeps this in mind separately from the issue above, but again, haven't seen this spelled out as part of it.
The text was updated successfully, but these errors were encountered:
C++ does use namespaces which help avoiding name pollution. However in C the usual way to do this is just using the "namespaces" as prefixes of the names. For functions and other ABI exports this cannot really be changed unless the export name is changed as well. However for types (typedefs, enums, structs) this can be prefixed by cbindgen so that the actual items do not need to have these extra prefixes in the Rust code. I tried looking at the code and added an option for it, but then I got lost because there was no way to extract the path to the item. An example could be something like:
This would (with the proper settings) result in:
where
asdf
is the name of the crate. This would make all the types and values uniquely identifiable the same way it is usually done in C libraries. That would help us with libraries that should be usable from C code and also porting some existing C code to Rust for which we currently need to write the header files manually.This does look similar to #7 although I do not see this particular thing mentioned there. If that is supposed to be a part of it, then feel free to close this.
Also it looks like #214 keeps this in mind separately from the issue above, but again, haven't seen this spelled out as part of it.
The text was updated successfully, but these errors were encountered: