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

"Unresolved link to i" when brackets are present in C/C++ comments #1955

Closed
nwmqpa opened this issue Dec 23, 2020 · 1 comment
Closed

"Unresolved link to i" when brackets are present in C/C++ comments #1955

nwmqpa opened this issue Dec 23, 2020 · 1 comment

Comments

@nwmqpa
Copy link

nwmqpa commented Dec 23, 2020

/**
 * Requests SpatialOS to create an entity. If components[i].schema_type is set, ownership is
 * transferred to the SDK, and components[i].schema_type is set to NULL. If
 * components[i].schema_type is NULL and components[i].user_handle is set, the entity data is
 * serialized immediately using the corresponding vtable serialize function.
 *
 * Returns Worker_RequestId -1 if the component is not registered and the default vtable is
 * not found.
 */
int64_t Worker_Connection_SendCreateEntityRequest(void* connection, uint32_t component_count, void* components, const void* entity_id, const uint32_t* timeout_millis);

Bindgen Invocation

bindgen::Builder::default()
            .header(
                path.clone()
                    .as_ref()
                    .join("dependencies/worker_sdk/headers/include/improbable/c_schema.h")
                    .to_str()
                    .expect("Can't convert path to utf-8")
                    .to_string(),
            )
            .header(
                path.clone()
                    .as_ref()
                    .join("dependencies/worker_sdk/headers/include/improbable/c_worker.h")
                    .to_str()
                    .expect("Can't convert path to utf-8")
                    .to_string(),
            )
            .header(
                path.clone()
                    .as_ref()
                    .join("dependencies/worker_sdk/headers/include/improbable/ngrpc.h")
                    .to_str()
                    .expect("Can't convert path to utf-8")
                    .to_string(),
            )
            .clang_args(&[
                &target
            ])
            .rustified_enum("*")
            .parse_callbacks(Box::new(bindgen::CargoCallbacks))
            .generate()
            .expect("Unable to generate bindings");

Actual Results

extern "C" {
    #[doc = " Requests SpatialOS to create an entity. If components[i].schema_type is set, ownership is"]
    #[doc = " transferred to the SDK, and components[i].schema_type is set to NULL. If"]
    #[doc = " components[i].schema_type is NULL and components[i].user_handle is set, the entity data is"]
    #[doc = " serialized immediately using the corresponding vtable serialize function."]
    #[doc = ""]
    #[doc = " Returns Worker_RequestId -1 if the component is not registered and the default vtable is"]
    #[doc = " not found."]
    pub fn Worker_Connection_SendCreateEntityRequest(
        connection: *mut ::std::os::raw::c_void,
        component_count: u32,
        components: *mut ::std::os::raw::c_void,
        entity_id: *const ::std::os::raw::c_void,
        timeout_millis: *const u32,
    ) -> i64;
}

Expected Results

extern "C" {
    #[doc = " Requests SpatialOS to create an entity. If components\[i\].schema_type is set, ownership is"]
    #[doc = " transferred to the SDK, and components\[i\].schema_type is set to NULL. If"]
    #[doc = " components\[i\].schema_type is NULL and components\[i\].user_handle is set, the entity data is"]
    #[doc = " serialized immediately using the corresponding vtable serialize function."]
    #[doc = ""]
    #[doc = " Returns Worker_RequestId -1 if the component is not registered and the default vtable is"]
    #[doc = " not found."]
    pub fn Worker_Connection_SendCreateEntityRequest(
        connection: *mut ::std::os::raw::c_void,
        component_count: u32,
        components: *mut ::std::os::raw::c_void,
        entity_id: *const ::std::os::raw::c_void,
        timeout_millis: *const u32,
    ) -> i64;
}

Due to a change in rust documentation generator, we now have the possibility to use scoped variable inside documentation by specifying it between brackets. However, when transpiling C/C++ Headers, this lead to the apparition of multiple warnings, due to the fact that this isn't a C behaviour.

The warning message in my case is

warning: unresolved link to `i`
    --> /home/tnicollet/Workspace/Project-StarDust/spatialos-sys/target/debug/build/spatialos-sys-bdfde63f736b4f18/out/bindings.rs:7900:5
     |
7900 | /     #[doc = " Requests SpatialOS to create an entity. If components[i].schema_type is set, ownership is"]
7901 | |     #[doc = " transferred to the SDK, and components[i].schema_type is set to NULL. If"]
7902 | |     #[doc = " components[i].schema_type is NULL and components[i].user_handle is set, the entity data is"]
7903 | |     #[doc = " serialized immediately using the corresponding vtable serialize function."]
7904 | |     #[doc = ""]
7905 | |     #[doc = " Returns Worker_RequestId -1 if the component is not registered and the default vtable is"]
7906 | |     #[doc = " not found."]
     | |__________________________^
     |
     = note: the link appears in this line:

             Requests SpatialOS to create an entity. If components[i].schema_type is set, ownership is
                                                                   ^
     = note: the module `ffi` contains no item named `i`
     = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
@pvdrz
Copy link
Contributor

pvdrz commented Apr 13, 2023

This can be fixed by providing a ParseCallbacks implementor now: #2347

@pvdrz pvdrz closed this as completed Apr 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants