Skip to content

_Atomic use on C++ compilers can cause issues #169

@joerowell

Description

@joerowell

I've noticed that cysignals uses _Atomic where it is available (c.f 8073803).

In C land, this is fine.

However, for C++ this is more questionable, and I've recently run into such an issue.

Essentially, the problem is that when installing cysignals the compiler used is fixed. This means that anyone wanting to use a generated cysignals in their code must use a compatible compiler, or there will be mismatches.

For example, on my Mac, the default C++ compiler is clang, which defines _Atomic. So, when cysignals has its headers configured, it is configured to use _Atomic.

However, if I then try to compile some code that uses cysignals using g++, I get a series of hard-to-diagnose errors. These errors occur precisely because cysignals expects _Atomic to exist, but it doesn't in g++.

I think the most straightforward thing to do is to not use _Atomic for C++ code. I'm happy to provide such a fix: equally, if there's a good reason why _Atomic is to be preferred, I'm also happy to try and produce a fix that satisfies both sides.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions