annotate libcxx/docs/DesignDocs/FeatureTestMacros.rst @ 150:1d019706d866

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