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

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

Open
wants to merge 1 commit into
base: noetic-devel
Choose a base branch
from

Conversation

SubaruArai
Copy link

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