Skip to content

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

Closed
@nwmqpa

Description

@nwmqpa
/**
 * 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 `\]`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions