132784a74SEric Fiselier=================== 232784a74SEric FiselierFeature Test Macros 332784a74SEric Fiselier=================== 432784a74SEric Fiselier 532784a74SEric Fiselier.. contents:: 632784a74SEric Fiselier :local: 732784a74SEric Fiselier 832784a74SEric FiselierOverview 932784a74SEric Fiselier======== 1032784a74SEric Fiselier 11*044b892cSMarek KurdejLibc++ implements the C++ feature test macros as specified in the C++20 standard, 12508da415SEric Fiselierand before that in non-normative guiding documents 13508da415SEric Fiselier(`See cppreference <https://en.cppreference.com/w/User:D41D8CD98F/feature_testing_macros>`_) 14508da415SEric Fiselier 1532784a74SEric Fiselier 1632784a74SEric FiselierDesign 1732784a74SEric Fiselier====== 1832784a74SEric Fiselier 1932784a74SEric FiselierFeature test macros are tricky to track, implement, test, and document correctly. 2032784a74SEric FiselierThey must be available from a list of headers, they may have different values in 2132784a74SEric Fiselierdifferent dialects, and they may or may not be implemented by libc++. In order to 2232784a74SEric Fiseliertrack all of these conditions correctly and easily, we want a Single Source of 2332784a74SEric FiselierTruth (SSoT) that defines each feature test macro, its values, the headers it 2432784a74SEric Fiselierlives in, and whether or not is is implemented by libc++. From this SSoA we 2532784a74SEric Fiselierhave enough information to automatically generate the `<version>` header, 2632784a74SEric Fiselierthe tests, and the documentation. 2732784a74SEric Fiselier 28508da415SEric FiselierTherefore we maintain a SSoA in `libcxx/utils/generate_feature_test_macro_components.py` 2932784a74SEric Fiselierwhich doubles as a script to generate the following components: 3032784a74SEric Fiselier 3132784a74SEric Fiselier* The `<version>` header. 3232784a74SEric Fiselier* The version tests under `support.limits.general`. 3332784a74SEric Fiselier* Documentation of libc++'s implementation of each macro. 3432784a74SEric Fiselier 3532784a74SEric FiselierUsage 3632784a74SEric Fiselier===== 3732784a74SEric Fiselier 3832784a74SEric FiselierThe `generate_feature_test_macro_components.py` script is used to track and 3932784a74SEric Fiselierupdate feature test macros in libc++. 4032784a74SEric Fiselier 4132784a74SEric FiselierWhenever a feature test macro is added or changed, the table should be updated 42647fb6b3SLouis Dionneand the script should be re-ran. The script will clobber the existing test files, 43647fb6b3SLouis Dionnethe documentation and the `<version>` header. 44