Skip to content

Enforce preprocessor to run with gnu11#21349

Closed
bangbangsheshotmedown wants to merge 1 commit intodlang:masterfrom
bangbangsheshotmedown:patch-5
Closed

Enforce preprocessor to run with gnu11#21349
bangbangsheshotmedown wants to merge 1 commit intodlang:masterfrom
bangbangsheshotmedown:patch-5

Conversation

@bangbangsheshotmedown
Copy link
Copy Markdown
Contributor

@bangbangsheshotmedown bangbangsheshotmedown commented May 6, 2025

After updating my machine, I started getting ton of errors like:

/usr/lib/gcc/x86_64-pc-linux-gnu/15.1.1/include/stddef.h(465): Error: undefined identifier `nullptr`, did you mean alias `nullptr_t`?

when using -std=c11 i get:

/usr/include/bits/mathcalls-helper-functions.h(21): Error: undefined identifier `_Float128`

when using -std=gnu11 it all works properly

Perhaps: #21311

@dlang-bot
Copy link
Copy Markdown
Contributor

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

@rikkimax
Copy link
Copy Markdown
Contributor

rikkimax commented May 6, 2025

From what I can see, this should work with both gcc and clang.

@kinke
Copy link
Copy Markdown
Contributor

kinke commented May 7, 2025

Seems reasonable to me. @the-horo?

For Windows/MSVC, we should probably use /std:c11 as well: https://learn.microsoft.com/en-us/cpp/build/reference/std-specify-language-standard-version?view=msvc-170. Apparently requires specific min VS 2019 / WinSDK versions though.

Copy link
Copy Markdown
Contributor

@the-horo the-horo left a comment

Choose a reason for hiding this comment

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

Can confirm that this fixes it for me. Other than the trailing space the only concern would be the fact that the std is gnu11 rather then c11. Given that this was the implicit value picked by the compilers (at least on linux) I don't think the PR needs to be adjusted.

argv.push(p);
}

argv.push("-std=gnu11");
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.

Suggested change
argv.push("-std=gnu11");
argv.push("-std=gnu11");

@the-horo
Copy link
Copy Markdown
Contributor

the-horo commented May 7, 2025

From what I can see, this should work with both gcc and clang.

It seems that clang-cpp fails with -std=gnu but not with -std=c:

// foo.c
#include <stdlib.h>
[happy@happypc] /tmp % dmd foo.c -cpp=clang-cpp -P=-std=c11 -o-
[happy@happypc] /tmp % dmd foo.c -cpp=clang-cpp -P=-std=gnu11 -o-
/usr/include/bits/floatn-common.h(214): Error: illegal combination of type specifiers
/usr/include/bits/floatn-common.h(251): Error: illegal combination of type specifiers
/usr/include/bits/floatn-common.h(268): Error: illegal combination of type specifiers
/usr/include/bits/floatn-common.h(285): Error: illegal combination of type specifiers
/usr/include/bits/floatn-common.h(285): Error: illegal type combination
[happy@happypc] /tmp % dmd foo.c -cpp=clang-cpp -o- # -P=-std=gnu17 the default
/usr/include/bits/floatn-common.h(214): Error: illegal combination of type specifiers
/usr/include/bits/floatn-common.h(251): Error: illegal combination of type specifiers
/usr/include/bits/floatn-common.h(268): Error: illegal combination of type specifiers
/usr/include/bits/floatn-common.h(285): Error: illegal combination of type specifiers
/usr/include/bits/floatn-common.h(285): Error: illegal type combination

@kinke
Copy link
Copy Markdown
Contributor

kinke commented May 7, 2025

I can confirm this. Also happens with clang -E as preprocessor driver (as used by LDC), needing -std=c11.

@the-horo
Copy link
Copy Markdown
Contributor

I've made another PR (#21372) for -std=c11 as well as #21371 for clang-cpp on linux x64.

@kinke
Copy link
Copy Markdown
Contributor

kinke commented May 14, 2025

Which have been merged - thx!

@kinke kinke closed this May 14, 2025
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.

5 participants