Skip to content

Conversation

StephanTLavavej
Copy link
Member

Defining _VCRT_ALLOW_INTERNALS allows <vcruntime_internal.h> to be dragged in:

#if !defined _VCRT_BUILD && !defined _VCRT_ALLOW_INTERNALS
    // This is an internal C Runtime header file.  It is used when building the
    // C Runtime only.  It is not to be used as a public header file.
    #error ERROR: Use of C Runtime library internal header file.
#endif

The entire STL build (in CMake and MSBuild) defines this macro, but only two translation units need it (for EH machinery). To prevent unintentionally using VCRuntime internals in the future, we should limit the use of the macro to where it's needed.

Ordinarily, I would hiss at defining macros in source files, as opposed to in the build system. However, because this merely guards an #error (instead of affecting something ODR-relevant), it's very safe to define this way. Defining per-file macros in the build system(s) is not worth the trouble here.

I've validated this with an internal build.

@StephanTLavavej StephanTLavavej added the enhancement Something can be improved label Jul 2, 2025
@StephanTLavavej StephanTLavavej requested a review from a team as a code owner July 2, 2025 07:09
@github-project-automation github-project-automation bot moved this to Initial Review in STL Code Reviews Jul 2, 2025
@StephanTLavavej StephanTLavavej moved this from Initial Review to Final Review in STL Code Reviews Jul 2, 2025
Copy link

@JamesMcNellis JamesMcNellis left a comment

Choose a reason for hiding this comment

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

LGTM 😄

Copy link
Member

@davidmrdavid davidmrdavid left a comment

Choose a reason for hiding this comment

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

LGTM as well

@StephanTLavavej StephanTLavavej moved this from Final Review to Ready To Merge in STL Code Reviews Jul 9, 2025
@StephanTLavavej StephanTLavavej moved this from Ready To Merge to Merging in STL Code Reviews Jul 14, 2025
@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 a3678cc into microsoft:main Jul 15, 2025
39 checks passed
@github-project-automation github-project-automation bot moved this from Merging to Done in STL Code Reviews Jul 15, 2025
@StephanTLavavej StephanTLavavej deleted the internal-affairs branch July 15, 2025 21:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Something can be improved
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants