146035553Spatrick=================== 246035553SpatrickFeature Test Macros 346035553Spatrick=================== 446035553Spatrick 546035553Spatrick.. contents:: 646035553Spatrick :local: 746035553Spatrick 846035553SpatrickOverview 946035553Spatrick======== 1046035553Spatrick 11*76d0caaeSpatrickLibc++ implements the C++ feature test macros as specified in the C++20 standard, 1246035553Spatrickand before that in non-normative guiding documents 1346035553Spatrick(`See cppreference <https://en.cppreference.com/w/User:D41D8CD98F/feature_testing_macros>`_) 1446035553Spatrick 1546035553Spatrick 1646035553SpatrickDesign 1746035553Spatrick====== 1846035553Spatrick 1946035553SpatrickFeature test macros are tricky to track, implement, test, and document correctly. 2046035553SpatrickThey must be available from a list of headers, they may have different values in 2146035553Spatrickdifferent dialects, and they may or may not be implemented by libc++. In order to 2246035553Spatricktrack all of these conditions correctly and easily, we want a Single Source of 2346035553SpatrickTruth (SSoT) that defines each feature test macro, its values, the headers it 2446035553Spatricklives in, and whether or not is is implemented by libc++. From this SSoA we 2546035553Spatrickhave enough information to automatically generate the `<version>` header, 2646035553Spatrickthe tests, and the documentation. 2746035553Spatrick 2846035553SpatrickTherefore we maintain a SSoA in `libcxx/utils/generate_feature_test_macro_components.py` 2946035553Spatrickwhich doubles as a script to generate the following components: 3046035553Spatrick 3146035553Spatrick* The `<version>` header. 3246035553Spatrick* The version tests under `support.limits.general`. 3346035553Spatrick* Documentation of libc++'s implementation of each macro. 3446035553Spatrick 3546035553SpatrickUsage 3646035553Spatrick===== 3746035553Spatrick 3846035553SpatrickThe `generate_feature_test_macro_components.py` script is used to track and 3946035553Spatrickupdate feature test macros in libc++. 4046035553Spatrick 4146035553SpatrickWhenever a feature test macro is added or changed, the table should be updated 42*76d0caaeSpatrickand the script should be re-ran. The script will clobber the existing test files, 43*76d0caaeSpatrickthe documentation and the `<version>` header. 44