libcxx

libcxx mirror with random patches
git clone https://git.neptards.moe/neptards/libcxx.git
Log | Files | Refs

FeatureTestMacros.rst (1732B)


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