Skip to content

Call C preprocessor with -std=c11 on posix#21372

Merged
thewilsonator merged 3 commits intodlang:masterfrom
the-horo:preprocessor-std-c11
May 13, 2025
Merged

Call C preprocessor with -std=c11 on posix#21372
thewilsonator merged 3 commits intodlang:masterfrom
the-horo:preprocessor-std-c11

Conversation

@the-horo
Copy link
Copy Markdown
Contributor

Like #21349 but uses -std=c11 instead of -std=gnu11

@the-horo the-horo requested a review from ibuclaw as a code owner May 13, 2025 16:47
@dlang-bot
Copy link
Copy Markdown
Contributor

Thanks for your pull request and interest in making D better, @the-horo! 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#21372"

// https://issues.dlang.org/show_bug.cgi?id=24187

#ifdef linux
#ifdef __linux__
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ah okay, so that's what made -std=gnu11 required with the GNU cpp?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Basically, yes:

[happy@happypc] ~ % gcc -E -std=gnu11 -dD -xc /dev/null | grep linux
#define __gnu_linux__ 1
#define __linux 1
#define __linux__ 1
#define linux 1
[happy@happypc] ~ % gcc -E -std=c11 -dD -xc /dev/null | grep linux
#define __gnu_linux__ 1
#define __linux 1
#define __linux__ 1

the-horo added 3 commits May 13, 2025 22:50
Stay consistent with the rest of the preprocessor conditionals by
checking for __linux__ instead of linux. Additionally, the former also
works with -std=c11 whereas the latter only works with -std=gnu11.

Signed-off-by: Andrei Horodniceanu <[email protected]>
With -std=c11, on linux, alloca no longer comes from stdlib.h.

Also fix the URL bug number which never pointed to the right one.

Signed-off-by: Andrei Horodniceanu <[email protected]>
Don't rely on the default -std value since gcc/clang updates may lead
to breakages. Additionally, the default value for both compiler
vendors, on linux at least, is a gnu variant rather then the ISO
standard.

Closes: dlang#21311
Signed-off-by: Andrei Horodniceanu <[email protected]>
@the-horo the-horo force-pushed the preprocessor-std-c11 branch from 46203a9 to d1aeeb7 Compare May 13, 2025 19:50
@thewilsonator thewilsonator merged commit b9e5364 into dlang:master May 13, 2025
40 of 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.

4 participants