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

Drop #pragma once in STL headers #3895

Merged
merged 3 commits into from
Jul 26, 2023

Conversation

StephanTLavavej
Copy link
Member

This drops #pragma once in stl/inc (and the generator grapheme_break_property_data_gen.py), relying on our classic idempotency guards (combined with modern compiler abilities to recognize and optimize them; C1XX gained that ability a while ago, so there should be no throughput regressions). This is an attempt to fix VSO-1830439 "[Feedback][std:c++latest] C++: 'is not a member' error when importing modules", a scenario which I don't fully understand, but which @cdacamar says will be fixed if the STL stops using #pragma once.

Elsewhere, we generally rely on #pragma once alone, which is fine. This contains a couple of tiny related cleanups for that (as they are extremely tiny and isolated into separate commits, they shouldn't interfere with reviewing the large mechanical change):

  • Move #pragma once to the top of tests/std/include/new_counter.hpp.
    • This may not be strictly necessary, but it is absolutely conventional elsewhere.
  • Rely on #pragma once in tests/tr1/include/cvt_xtest.h, as it isn't product code anymore.
    • There are all sorts of other cleanups that could be performed here, but we generally avoid messing with tr1. In this case, I thought it was worth a change to follow the principle "product code avoids #pragma once, test code uses it".

⚠️ We should also create PRs for the feature branches in order to avoid this re-appearing.

@StephanTLavavej StephanTLavavej added bug Something isn't working modules C++23 modules, C++20 header units labels Jul 21, 2023
@StephanTLavavej StephanTLavavej requested a review from a team as a code owner July 21, 2023 00:49
@StephanTLavavej
Copy link
Member Author

I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed.

@StephanTLavavej StephanTLavavej merged commit 92d050e into microsoft:main Jul 26, 2023
37 checks passed
@StephanTLavavej StephanTLavavej deleted the pragma-zero branch July 26, 2023 18:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working modules C++23 modules, C++20 header units
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants