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