Skip to content

fixed nh.getParam template with gcc-arm-none-eabi#587

Open
SubaruArai wants to merge 1 commit into
ros-drivers:noetic-develfrom
SubaruArai:fix_int
Open

fixed nh.getParam template with gcc-arm-none-eabi#587
SubaruArai wants to merge 1 commit into
ros-drivers:noetic-develfrom
SubaruArai:fix_int

Conversation

@SubaruArai

Copy link
Copy Markdown

with the following code:

template <typename T>
static inline T get_single_param_(const char *param_name, T default_value)
{
    std::array<T, 1> buf;
    if (nh.getParam(param_name, buf.data())) {
        return buf[0];
    } else {
        return default_value;
    }
}

Under rp2040 (arm-none-eabi-gcc, 32bit), if T is "int", gcc will convert
the int to "short int" thus failing compilation.
Using "int32_t" for T didn't help, and fundamentally it's a problem of
"int" not being really cross-platform.
Changing the "int" in rosserial_client.h to "int32_t" fixed the issue.

Ultimately, all "int" in the codebase should be "int32_t" including
message_generation, but that would be a breaking change.

Even this change might be breaking for some codes.

with the following code:
```cpp
template <typename T>
static inline T get_single_param_(const char *param_name, T default_value)
{
    std::array<T, 1> buf;
    if (nh.getParam(param_name, buf.data())) {
        return buf[0];
    } else {
        return default_value;
    }
}
```
Under rp2040 (arm-none-eabi-gcc, 32bit), if T is "int", gcc will convert
the int to "short int" thus failing compilation.
Using "int32_t" for T didn't help, and fundamentally it's a problem of
"int" not being really cross-platform.
Changing the "int" in rosserial_client to "int32_t" fixed the issue.

Ultimately, all "int" in the codebase should be "int32_t" including
message_generation, but that would be a breaking change.

Even this change might be breaking for some codes.
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

Successfully merging this pull request may close these issues.

1 participant