Skip to content

Commit de060c5

Browse files
fsb4000misccoAdamBuciorStephanTLavavej
authored
add _ENFORCE_ONLY_CORE_HEADERS (#2068)
Co-authored-by: Michael Schellenberger Costa <[email protected]> Co-authored-by: Adam Bucior <[email protected]> Co-authored-by: Stephan T. Lavavej <[email protected]>
1 parent 8ca7bd3 commit de060c5

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

stl/inc/yvals.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@
99
#include <yvals_core.h>
1010
#if _STL_COMPILER_PREPROCESSOR
1111

12+
#ifdef _ENFORCE_ONLY_CORE_HEADERS
13+
_EMIT_STL_ERROR(
14+
STL1005, "Tried to include a non-core C++ Standard Library header file with _ENFORCE_ONLY_CORE_HEADERS defined.");
15+
#endif // _ENFORCE_ONLY_CORE_HEADERS
16+
1217
#include <crtdbg.h>
1318
#include <crtdefs.h>
1419

stl/inc/yvals_core.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1232,6 +1232,8 @@ _EMIT_STL_ERROR(STL1004, "C++98 unexpected() is incompatible with C++23 unexpect
12321232

12331233
// next warning number: STL4040
12341234

1235+
// next error number: STL1006
1236+
12351237
// P0619R4 Removing C++17-Deprecated Features
12361238
#ifndef _HAS_FEATURES_REMOVED_IN_CXX20
12371239
#define _HAS_FEATURES_REMOVED_IN_CXX20 (!_HAS_CXX20)

tests/std/tests/GH_001411_core_headers/test.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
33

44
#define _CORE_HEADERS_ONLY
5+
#define _ENFORCE_ONLY_CORE_HEADERS // Also test GH-311 "Make it easy to limit the STL to core features"
56

67
#include <__msvc_all_public_headers.hpp>
78

0 commit comments

Comments
 (0)