Rename endian.h to portable_endian.h#442
Rename endian.h to portable_endian.h#442urrsk wants to merge 3 commits intoUniversalRobots:masterfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #442 +/- ##
==========================================
+ Coverage 75.70% 76.38% +0.67%
==========================================
Files 105 105
Lines 5536 5542 +6
Branches 593 593
==========================================
+ Hits 4191 4233 +42
+ Misses 1050 1011 -39
- Partials 295 298 +3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
df8a74b to
8af9e9f
Compare
urfeex
left a comment
There was a problem hiding this comment.
Looking good in general, but I don't understand why so many implementation files now need to include that header, as well as the tests. Shouldn't that be unnecessary, when only the serializer, parser and package header cpp files include it?
|
Just a casual observer (and observation): byte swapping is often kept header only (in C/C++) to give the compiler maximum opportunity to in-line it (which can result in swaps becoming no-ops when source and target use identical order). Refactoring it into a separate shared library seems to complicate that -- unless something like LTO is used (but I'm not sure that's possible with functions from shared libraries). Performance is probably not necessarily a concern here, but something to keep in mind perhaps (at 500 Hz there could be measurable effects). |
Thanks @gavanderhoorn for that point. |
|
@urrsk wrote:
but in order to be able to in-line, that header is used, right? Is the main issue just to have to install a |
Well yes. Though this work was motivated to avoid the circular include due to the naming, and then I when all the way to avoid it in the headers to limit the overhead. |
d4af991 to
ff2bb61
Compare
|
I have changed the scope and reverted the cpp files approach. Thanks for the inspiration from @gavanderhoorn. |
|
@traversaro, @acmorrow Would you happen to have an opinion on this change? |
This change is a really good idea! Did you considered also changing the install path from |
I agree with the above. This seems like a solid improvement. I would recommend maybe looking for another source of endian conversion functions in the long term. While boost and abseil both provide such, it does seem from a quick look at the CMakeLists.txt that this library is attempting to have few if any heavyweight and/or non-vendored third-party dependencies, and that's a choice I can appreciate. But at least with C++20 and C++23 you have std::byteswap and std::endian. You could write a small non-macro based header that provides a polyfill under those names, or find one. |
|
Thank you both @traversaro @acmorrow for your prompt and valuable feedback! |
7e45932 to
e7b907f
Compare
|
@traversaro thanks for the feedback. With my last commit, I have tried to implement your suggestions. You both more than welcome to common my changes. The goal is to make it easier to integrate and use. |
|
Great, thanks! |
This change renames the endian.h file to portable_endian.h to avoid conflicts caused by circular includes. The third-party endian.h file includes the system's endian.h, which can lead to circular imports due to overlapping filenames. By renaming the file, we eliminate this issue and ensure compatibility in the CMake build process. Finally, a macOS CI build has been added to verify that the library builds successfully on macOS, ensuring cross-platform compatibility.
Co-authored-by: Felix Exner <feex@universal-robots.com>
- Change to use #pragma once - Now checking before defining a macro - Move the header to make it easier for third-party to use the URCL Thanks @traversaro
This change renames the endian.h file to portable_endian.h to avoid conflicts caused by circular includes. The third-party endian.h file includes the system's endian.h, which can lead to circular imports due to overlapping filenames. By renaming the file, we eliminate this issue and ensure compatibility in the CMake build process.
Finally, a macOS CI build has been added to verify that the library builds successfully on macOS, ensuring cross-platform compatibility.
Note
Medium Risk
Updates the project-wide endian conversion include and removes the previously-installed
3rdparty/endianheader, which could break downstream builds that referenced the old path/name. While intended to be a no-behavior-change portability fix, it touches binary parsing/serialization codepaths and cross-platform build configuration.Overview
Resolves
endian.hinclude-name conflicts by replacing the vendored3rdparty/endian/endian.hwith a library-ownedinclude/ur_client_library/portable_endian.h, and switches call sites to include that header instead of<endian.h>.CMake install/include wiring for the old third-party header is removed, and CI is expanded with a new macOS (arm64 + x86_64) build/test workflow plus scheduled runs for Windows. Tests are strengthened/adjusted around
BinParserandPackageSerializerendian encode/decode behavior (additional coverage and corrected assertions for int/bool/double cases).Written by Cursor Bugbot for commit e8522d5. This will update automatically on new commits. Configure here.