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 atomics in C++ #23

Merged
merged 1 commit into from
Dec 19, 2023
Merged

Fix atomics in C++ #23

merged 1 commit into from
Dec 19, 2023

Conversation

maxim-sloyko-yohana
Copy link
Collaborator

atomic_int and atomic_flag in C++ are not macros, but typedefs, thus #ifndef check fails and C++ users get this macro defined for atomic_int:

`#`define atomic_int std::atomic<int>

If then somebody tries to use atomic_int with a fully qualified name, i.e. as std::atomic_int, they get a cryptic error saying std in namespace std does not name a type.

Simply importing atomic_int and atomic_flag into a global namespace fixes the issue, as this means that both uses are legal:

  • atomic_int, which is what used in Event Router
  • std::atomic_int, which might be used in other C++ code.

`atomic_int` and `atomic_flag` in C++ are not macros, but typedefs, thus
`#ifndef` check fails and C++ users get this macro defined for
`atomic_int`:

```c++
`#`define atomic_int std::atomic<int>
```

If then somebody tries to use `atomic_int` with a fully qualified name,
i.e. as `std::atomic_int`, they get a cryptic error saying `std in
namespace std does not name a type`.

Simply importing `atomic_int` and `atomic_flag` into a global namespace
fixes the issue, as this means that both uses are legal:

* `atomic_int`, which is what used in Event Router
* `std::atomic_int`, which might be used in other C++ code.
Copy link
Collaborator

@jd-yolabs jd-yolabs left a comment

Choose a reason for hiding this comment

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

Please merge if you verified that this works on RealTek devices. Thanks for fixing this.

@maxim-sloyko-yohana maxim-sloyko-yohana merged commit 2fc9379 into main Dec 19, 2023
1 check passed
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.

2 participants