Home | History | Annotate | Line # | Download | only in DesignDocs
FeatureTestMacros.rst revision 1.1
      1  1.1  joerg ===================
      2  1.1  joerg Feature Test Macros
      3  1.1  joerg ===================
      4  1.1  joerg 
      5  1.1  joerg .. contents::
      6  1.1  joerg    :local:
      7  1.1  joerg 
      8  1.1  joerg Overview
      9  1.1  joerg ========
     10  1.1  joerg 
     11  1.1  joerg Libc++ implements the C++ feature test macros as specified in the C++20 standard,
     12  1.1  joerg and before that in non-normative guiding documents
     13  1.1  joerg (`See cppreference <https://en.cppreference.com/w/User:D41D8CD98F/feature_testing_macros>`_)
     14  1.1  joerg 
     15  1.1  joerg 
     16  1.1  joerg Design
     17  1.1  joerg ======
     18  1.1  joerg 
     19  1.1  joerg Feature test macros are tricky to track, implement, test, and document correctly.
     20  1.1  joerg They must be available from a list of headers, they may have different values in
     21  1.1  joerg different dialects, and they may or may not be implemented by libc++. In order to
     22  1.1  joerg track all of these conditions correctly and easily, we want a Single Source of
     23  1.1  joerg Truth (SSoT) that defines each feature test macro, its values, the headers it
     24  1.1  joerg lives in, and whether or not is is implemented by libc++. From this SSoA we
     25  1.1  joerg have enough information to automatically generate the `<version>` header,
     26  1.1  joerg the tests, and the documentation.
     27  1.1  joerg 
     28  1.1  joerg Therefore we maintain a SSoA in `libcxx/utils/generate_feature_test_macro_components.py`
     29  1.1  joerg which doubles as a script to generate the following components:
     30  1.1  joerg 
     31  1.1  joerg * The `<version>` header.
     32  1.1  joerg * The version tests under `support.limits.general`.
     33  1.1  joerg * Documentation of libc++'s implementation of each macro.
     34  1.1  joerg 
     35  1.1  joerg Usage
     36  1.1  joerg =====
     37  1.1  joerg 
     38  1.1  joerg The `generate_feature_test_macro_components.py` script is used to track and
     39  1.1  joerg update feature test macros in libc++.
     40  1.1  joerg 
     41  1.1  joerg Whenever a feature test macro is added or changed, the table should be updated
     42  1.1  joerg and the script should be re-ran. The script will clobber the existing test files,
     43  1.1  joerg the documentation and the `<version>` header.
     44