1*4d6fc14bSjoerg=================== 2*4d6fc14bSjoergFeature Test Macros 3*4d6fc14bSjoerg=================== 4*4d6fc14bSjoerg 5*4d6fc14bSjoerg.. contents:: 6*4d6fc14bSjoerg :local: 7*4d6fc14bSjoerg 8*4d6fc14bSjoergOverview 9*4d6fc14bSjoerg======== 10*4d6fc14bSjoerg 11*4d6fc14bSjoergLibc++ implements the C++ feature test macros as specified in the C++20 standard, 12*4d6fc14bSjoergand before that in non-normative guiding documents 13*4d6fc14bSjoerg(`See cppreference <https://en.cppreference.com/w/User:D41D8CD98F/feature_testing_macros>`_) 14*4d6fc14bSjoerg 15*4d6fc14bSjoerg 16*4d6fc14bSjoergDesign 17*4d6fc14bSjoerg====== 18*4d6fc14bSjoerg 19*4d6fc14bSjoergFeature test macros are tricky to track, implement, test, and document correctly. 20*4d6fc14bSjoergThey must be available from a list of headers, they may have different values in 21*4d6fc14bSjoergdifferent dialects, and they may or may not be implemented by libc++. In order to 22*4d6fc14bSjoergtrack all of these conditions correctly and easily, we want a Single Source of 23*4d6fc14bSjoergTruth (SSoT) that defines each feature test macro, its values, the headers it 24*4d6fc14bSjoerglives in, and whether or not is is implemented by libc++. From this SSoA we 25*4d6fc14bSjoerghave enough information to automatically generate the `<version>` header, 26*4d6fc14bSjoergthe tests, and the documentation. 27*4d6fc14bSjoerg 28*4d6fc14bSjoergTherefore we maintain a SSoA in `libcxx/utils/generate_feature_test_macro_components.py` 29*4d6fc14bSjoergwhich doubles as a script to generate the following components: 30*4d6fc14bSjoerg 31*4d6fc14bSjoerg* The `<version>` header. 32*4d6fc14bSjoerg* The version tests under `support.limits.general`. 33*4d6fc14bSjoerg* Documentation of libc++'s implementation of each macro. 34*4d6fc14bSjoerg 35*4d6fc14bSjoergUsage 36*4d6fc14bSjoerg===== 37*4d6fc14bSjoerg 38*4d6fc14bSjoergThe `generate_feature_test_macro_components.py` script is used to track and 39*4d6fc14bSjoergupdate feature test macros in libc++. 40*4d6fc14bSjoerg 41*4d6fc14bSjoergWhenever a feature test macro is added or changed, the table should be updated 42*4d6fc14bSjoergand the script should be re-ran. The script will clobber the existing test files, 43*4d6fc14bSjoergthe documentation and the `<version>` header. 44