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

Fix uchar.h / char16_t detection/handling (fix #8) #10

Merged
merged 1 commit into from
Aug 29, 2023

Conversation

gavanderhoorn
Copy link
Contributor

Fix incorrect check: if __has_include(..) was supported, but uchar.h did not exist, char16_t never got typedefed with the changes to the conditionals made by #8.

It needs to be typedefed in (at least) two cases:

  1. uchar.h does not exist, and
  2. __has_include(..) is not supported

In case of the former, the type is most likely missing. In case of the latter, uchar.h could exist, but existence can't be checked, so the code is conservative and just typedefs char16_t itself.

@gavanderhoorn
Copy link
Contributor Author

@pablogs9: I believe this should work for the compilers/build envs you're using/supporting.

Apologies for breaking things with #8.

Fix incorrect check: if `__has_include(..)` was supported, but `uchar.h` did not exist, `char16_t` never got `typedef`ed.

It needs to be `typedef`ed in (at least) two cases:

1. `uchar.h` does not exist, and
2. `__has_include(..)` is not supported

In case of the former, the type is most likely missing. In case of the latter, `uchar.h` could exist, but existence can't be checked.

Note: checking for `__has_include(..)` support and use of the macro in a combined conditional is non-portable according to the documentation, hence the split.
@atticusrussell
Copy link

It would be great to get this merged - bug from #8 currently breaks CI in a project.
linorobot/linorobot2_hardware#62

Copy link
Contributor

@clalancette clalancette left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks OK to me. Let's run CI on it again.

@clalancette
Copy link
Contributor

CI:

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Windows Build Status

@clalancette
Copy link
Contributor

All right, CI is green. I'm going to go ahead and merge this, but I'm going to hold off on attempting a backport to see if we get any other reports (positive or negative) about this change.

@clalancette clalancette merged commit 917e764 into ros2:rolling Aug 29, 2023
2 checks passed
@pablogs9
Copy link
Member

I cannot launch a new nightly from my mobile, so I relaunch yesterday's: https://github.com/micro-ROS/micro_ros_setup/actions/runs/6007791161

If this is green, I'm ok with the backport.

BTW: I will check code in detail next week but, is there a real need of using char16_t? Why not using the wide supported uint16_t?

@gavanderhoorn
Copy link
Contributor Author

gavanderhoorn commented Aug 30, 2023

@pablogs9: jobs seem to all have succeeded.

The just finished nightly build also seems to be green.

I will check code in detail next week but, is there a real need of using char16_t? Why not using the wide supported uint16_t?

tbh I don't know.

I was just 'here' to fix a build issue.


Edit: looks like char16_t is used for widestring support (here fi). char16_t makes sense I guess.

@gavanderhoorn gavanderhoorn deleted the patch-1 branch August 30, 2023 05:19
@clalancette
Copy link
Contributor

BTW: I will check code in detail next week but, is there a real need of using char16_t? Why not using the wide supported uint16_t?

Because we are using this for handling wstring, which is explicitly char16_t. My understanding is that char16_t may or may not be equivalent to uint16_t, e.g. it might be signed depending on the platform.

@pablogs9
Copy link
Member

pablogs9 commented Aug 30, 2023

In that case it makes sense...
We just need to be a bit careful about the conditional includes.

Thanks a lot for taking care of this @gavanderhoorn @clalancette.

As CI is green for micro-ROS in rolling, for me it is ok to backport to iron.

@gavanderhoorn
Copy link
Contributor Author

[..] for me it is ok to backport to iron.

I would very much appreciate a backport indeed.

@gavanderhoorn
Copy link
Contributor Author

gavanderhoorn commented Sep 8, 2023

[..] I'm going to hold off on attempting a backport to see if we get any other reports (positive or negative) about this change.

Seeing as it's been a week without any additional reports: could this be backported to iron?

clalancette pushed a commit that referenced this pull request Sep 13, 2023
Fix incorrect check: if `__has_include(..)` was supported, but `uchar.h` did not exist, `char16_t` never got `typedef`ed.

It needs to be `typedef`ed in (at least) two cases:

1. `uchar.h` does not exist, and
2. `__has_include(..)` is not supported

In case of the former, the type is most likely missing. In case of the latter, `uchar.h` could exist, but existence can't be checked.

Note: checking for `__has_include(..)` support and use of the macro in a combined conditional is non-portable according to the documentation, hence the split.
clalancette pushed a commit that referenced this pull request Sep 14, 2023
* uchar: use __has_include(..) on separate line (#8)

Older compilers/preprocessors don't always support/implement short-circuit conditional evaluation, leading to attempts to evaluate `__has_include(..)` while `if defined(__has_include)` was actually `false`.

Split the conditional into two separate checks to avoid this.

(cherry picked from commit 88e2d7d)

* uchar: fix conditional include/typedef (#10)

Fix incorrect check: if `__has_include(..)` was supported, but `uchar.h` did not exist, `char16_t` never got `typedef`ed.

It needs to be `typedef`ed in (at least) two cases:

1. `uchar.h` does not exist, and
2. `__has_include(..)` is not supported

In case of the former, the type is most likely missing. In case of the latter, `uchar.h` could exist, but existence can't be checked.

Note: checking for `__has_include(..)` support and use of the macro in a combined conditional is non-portable according to the documentation, hence the split.

---------

Co-authored-by: G.A. vd. Hoorn <g.a.vanderhoorn@tudelft.nl>
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.

None yet

4 participants