File: FeatureTestMacros.rst

package info (click to toggle)
llvm-toolchain-13 1%3A13.0.1-6~deb11u1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 1,418,812 kB
  • sloc: cpp: 5,290,827; ansic: 996,570; asm: 544,593; python: 188,212; objc: 72,027; lisp: 30,291; f90: 25,395; sh: 24,900; javascript: 9,780; pascal: 9,398; perl: 7,484; ml: 5,432; awk: 3,523; makefile: 2,892; xml: 953; cs: 573; fortran: 539
file content (43 lines) | stat: -rw-r--r-- 1,562 bytes parent folder | download | duplicates (28)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
===================
Feature Test Macros
===================

.. contents::
   :local:

Overview
========

Libc++ implements the C++ feature test macros as specified in the C++20 standard,
and before that in non-normative guiding documents
(`See cppreference <https://en.cppreference.com/w/User:D41D8CD98F/feature_testing_macros>`_)


Design
======

Feature test macros are tricky to track, implement, test, and document correctly.
They must be available from a list of headers, they may have different values in
different dialects, and they may or may not be implemented by libc++. In order to
track all of these conditions correctly and easily, we want a Single Source of
Truth (SSoT) that defines each feature test macro, its values, the headers it
lives in, and whether or not is is implemented by libc++. From this SSoA we
have enough information to automatically generate the `<version>` header,
the tests, and the documentation.

Therefore we maintain a SSoA in `libcxx/utils/generate_feature_test_macro_components.py`
which doubles as a script to generate the following components:

* The `<version>` header.
* The version tests under `support.limits.general`.
* Documentation of libc++'s implementation of each macro.

Usage
=====

The `generate_feature_test_macro_components.py` script is used to track and
update feature test macros in libc++.

Whenever a feature test macro is added or changed, the table should be updated
and the script should be re-ran. The script will clobber the existing test files,
the documentation and the `<version>` header.