FeatureTestMacros.rst 1.6 KB

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