Skip to content

Conversation

@pbackus
Copy link
Contributor

@pbackus pbackus commented Feb 27, 2025

MSVC does not support C11 atomics, but it still provides a "stub" version of stdatomic.h, which aborts compilation with an #error directive when included.

To avoid this error, explicitly set the C standard to C11 when invoking the C preprocessor on Windows, and check for the C11 macro __STDC_NO_ATOMICS__ before including stdatomic.h.


Found in dlang/phobos#10650 (comment)

@dlang-bot
Copy link
Contributor

Thanks for your pull request and interest in making D better, @pbackus! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please verify that your PR follows this checklist:

  • My PR is fully covered with tests (you can see the coverage diff by visiting the details link of the codecov check)
  • My PR is as minimal as possible (smaller, focused PRs are easier to review than big ones)
  • I have provided a detailed rationale explaining my changes
  • New or modified functions have Ddoc comments (with Params: and Returns:)

Please see CONTRIBUTING.md for more information.


If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment.

Bugzilla references

Your PR doesn't reference any Bugzilla issue.

If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.

Testing this PR locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub run digger -- build "master + dmd#20922"

@pbackus pbackus marked this pull request as draft February 27, 2025 16:19
@pbackus pbackus force-pushed the fix-importc-msvc-ci branch 2 times, most recently from 1d5f8b8 to 5fe2a3a Compare February 27, 2025 17:39
MSVC does not support C11 atomics, but it still provides a "stub"
version of stdatomic.h, which aborts compilation with an #error
directive when included.

To avoid this error, explicitly set the C standard to C11 when invoking
the C preprocessor on Windows, and check for the C11 macro
__STDC_NO_ATOMICS__ before including stdatomic.h.
@pbackus pbackus force-pushed the fix-importc-msvc-ci branch from 5fe2a3a to 6299fce Compare February 27, 2025 18:12
@pbackus pbackus marked this pull request as ready for review February 27, 2025 18:34
@dkorpel dkorpel merged commit 5fc1141 into dlang:master Feb 27, 2025
42 checks 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.

3 participants