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

Macro conflict between sys/ioctl.h and hfsm2/machine.hpp #63

Closed
spiderkeys opened this issue Dec 14, 2021 · 4 comments
Closed

Macro conflict between sys/ioctl.h and hfsm2/machine.hpp #63

spiderkeys opened this issue Dec 14, 2021 · 4 comments

Comments

@spiderkeys
Copy link

spiderkeys commented Dec 14, 2021

I discovered today that there appears to be a conflict between HFSM2 and the Linux libc sys/ioctl.h header that causes a bizarre cascade of template errors and syntax errors.

The conflict occurs when including sys/ioctl.h before hfsm2/machine.hpp, due to HFSM2's use of the symbol NCC in various template arguments in machine.hpp:
https://github.com/andrew-gresyk/HFSM2/blob/master/include/hfsm2/machine.hpp#L3562

NCC is defined as an integer literal in <bits/ioctl-types.h> which gets included by <sys/ioctl.h>:
https://github.com/raspberrypi/tools/blob/master/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/arm-linux-gnueabihf/libc/usr/include/arm-linux-gnueabihf/bits/ioctl-types.h#L36

After renaming NCC to _NCC in HFSM2, I can confirm that the errors are resolved.

It's a bit unfortunate that the ioctl.h header causes this macro pollution. I'm not sure if there is any better fix than renaming the template argument in HFSM2 or maybe #undef'ing the symbol...

@andrew-gresyk
Copy link
Owner

andrew-gresyk commented Dec 14, 2021 via email

@andrew-gresyk
Copy link
Owner

@spiderkeys
Copy link
Author

Hi @andrew-gresyk. I just went to update our HFSM2 to the latest version and it looks like at some point this symbol name switched back from NCC_ to NCC, raising this issue again.

andrew-gresyk added a commit that referenced this issue Dec 9, 2022
andrew-gresyk added a commit that referenced this issue Dec 9, 2022
* renamed `NCC` to `NCC_` for #63
* configure `cmake.yml` action to download and install `clang-10`
* changed `clang-6` through `clang-11` builds to use `ubuntu-20.04`
* changed `clang-13` builds to use default version on `ubuntu-latest`
* added `clang-14`
@andrew-gresyk
Copy link
Owner

andrew-gresyk commented Dec 9, 2022

Thanks for reporting @spiderkeys
This should be fixed in 2.2.2

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

No branches or pull requests

2 participants