guidelines.qbk 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. [/
  2. Boost.Config
  3. Copyright (c) 2001 Beman Dawes
  4. Copyright (c) 2001 Vesa Karvonen
  5. Copyright (c) 2001 John Maddock
  6. Distributed under the Boost Software License, Version 1.0.
  7. (See accompanying file LICENSE_1_0.txt or copy at
  8. http://www.boost.org/LICENSE_1_0.txt)
  9. ]
  10. [section Guidelines for Boost Authors]
  11. The __BOOST_CONFIG_HEADER__ header is used to pass configuration information
  12. to other boost files, allowing them to cope with platform dependencies such
  13. as arithmetic byte ordering, compiler pragmas, or compiler shortcomings.
  14. Without such configuration information, many current compilers would not work
  15. with the Boost libraries.
  16. Centralizing configuration information in this header reduces the number of
  17. files that must be modified when porting libraries to new platforms, or when
  18. compilers are updated. Ideally, no other files would have to be modified when
  19. porting to a new platform.
  20. Configuration headers are controversial because some view them as condoning
  21. broken compilers and encouraging non-standard subsets. Adding settings for
  22. additional platforms and maintaining existing settings can also be a problem.
  23. In other words, configuration headers are a necessary evil rather than a
  24. desirable feature. The boost config.hpp policy is designed to minimize the
  25. problems and maximize the benefits of a configuration header.
  26. Note that:
  27. * Boost library implementers are not required to "`#include <boost/config.hpp>`",
  28. and are not required in any way to support compilers that do not comply
  29. with the C++ Standard (ISO/IEC 14882).
  30. * If a library implementer wishes to support some non-conforming compiler,
  31. or to support some platform specific feature, "`#include <boost/config.hpp>`"
  32. is the preferred way to obtain configuration information not available from
  33. the standard headers such as `<climits>`, etc.
  34. * If configuration information can be deduced from standard headers such as
  35. `<climits>`, use those standard headers rather than `<boost/config.hpp>`.
  36. * Boost files that use macros defined in `<boost/config.hpp>` should have
  37. sensible, standard conforming, default behavior if the macro is not defined.
  38. This means that the starting point for porting `<boost/config.hpp>` to a new
  39. platform is simply to define nothing at all specific to that platform. In
  40. the rare case where there is no sensible default behavior, an #error message
  41. should describe the problem.
  42. * If a Boost library implementer wants something added to `config.hpp`, post
  43. a request on the Boost mailing list. There is no guarantee such a request
  44. will be honored; the intent is to limit the complexity of config.hpp.
  45. * The intent is to support only compilers which appear on their way to
  46. becoming C++ Standard compliant, and only recent releases of those compilers
  47. at that.
  48. * The intent is not to disable mainstream features now well-supported by the
  49. majority of compilers, such as namespaces, exceptions, RTTI, or templates.
  50. [section:warnings Disabling Compiler Warnings]
  51. The header `<boost/config/warning_disable.hpp>` can be used to disable
  52. certain compiler warnings that are hard or impossible to otherwise remove.
  53. Note that:
  54. * This header [*['should never be included by another Boost header]], it should
  55. only ever be used by a library source file or a test case.
  56. * The header should be included [*['before you include any other header]].
  57. * This header only disables warnings that are hard or impossible to otherwise
  58. deal with, and which are typically emitted by one compiler only, or
  59. in one compilers own standard library headers.
  60. Currently it disables the following warnings:
  61. [table
  62. [[Compiler][Warning]]
  63. [[Visual C++ 8 and later][[@http://msdn2.microsoft.com/en-us/library/ttcz0bys(VS.80).aspx C4996]: Error 'function': was declared deprecated]]
  64. [[Intel C++][Warning 1786: relates to the use of "deprecated" standard
  65. library functions rather like C4996 in Visual C++.]]
  66. ]
  67. [endsect]
  68. [section Adding New Defect Macros]
  69. When you need to add a new defect macro - either to fix a problem with an
  70. existing library, or when adding a new library - distil the issue down to
  71. a simple test case; often, at this point other (possibly better) workarounds
  72. may become apparent. Secondly always post the test case code to the boost
  73. mailing list and invite comments; remember that C++ is complex and that
  74. sometimes what may appear a defect, may in fact turn out to be a problem
  75. with the authors understanding of the standard.
  76. When you name the macro, follow the `BOOST_NO_`['SOMETHING] naming
  77. convention, so that it's obvious that this is a macro reporting a defect.
  78. Finally, add the test program to the regression tests. You will need to
  79. place the test case in a `.ipp` file with the following comments near the top:
  80. // MACRO: BOOST_NO_FOO
  81. // TITLE: foo
  82. // DESCRIPTION: If the compiler fails to support foo
  83. These comments are processed by the autoconf script, so make sure the format
  84. follows the one given. The file should be named "`boost_no_foo.ipp`", where foo
  85. is the defect description - try and keep the file name under the Mac 30 character
  86. filename limit though. You will also need to provide a function prototype
  87. "`int test()`" that is declared in a namespace with the same name as the macro,
  88. but in all lower case, and which returns zero on success:
  89. namespace boost_no_foo {
  90. int test()
  91. {
  92. // test code goes here:
  93. //
  94. return 0;
  95. }
  96. }
  97. Once the test code is in place in libs/config/test, updating the configuration
  98. test system proceeds as:
  99. * cd into `libs/config/tools` and run `bjam`. This generates the `.cpp`
  100. file test cases from the `.ipp` file, updates the
  101. libs/config/test/all/Jamfile.v2, `config_test.cpp` and `config_info.cpp`.[br][br]
  102. * cd into `libs/config/test/all` and run `bjam `['MACRONAME` compiler-list`], where
  103. ['MACRONAME] is the name of the new macro, and ['`compiler-list`] is a space separated list of
  104. compilers to test with.[br][br]
  105. The xxx_pass_test and the xxx_fail_test [*should both report `**passed**`].[br][br]
  106. If ['MACRONAME] is not defined when it should be defined, xxx_pass_test will not report `**passed**`.
  107. If ['MACRONAME] is defined when it should not be defined, xxx_fail_test will not report `**passed**`.[br][br]
  108. * cd into `libs/config/test` and run `bjam config_info config_test `['`compiler-list`].
  109. `config_info` should build and run cleanly for all the compilers in ['`compiler-list`]
  110. while `config_test` should fail for those that have the defect, and pass for those
  111. that do not.
  112. Then you should:
  113. * Define the defect macro in those config headers that require it.
  114. * Document the macro in this documentation (please do not forget this step!!)
  115. * Commit everything.
  116. * Keep an eye on the regression tests for new failures in Boost.Config caused by
  117. the addition.
  118. * Start using the macro.
  119. [endsect]
  120. [section Adding New Feature Test Macros]
  121. When you need to add a macro that describes a feature that the standard does
  122. not require, follow the convention for adding a new defect macro (above), but
  123. call the macro `BOOST_HAS_FOO`, and name the test file "`boost_has_foo.ipp`".
  124. Try not to add feature test macros unnecessarily, if there is a platform
  125. specific macro that can already be used (for example `_WIN32`, `__BEOS__`, or
  126. `__linux`) to identify the feature then use that. Try to keep the macro to a
  127. feature group, or header name, rather than one specific API (for example
  128. `BOOST_HAS_NL_TYPES_H` rather than `BOOST_HAS_CATOPEN`). If the macro
  129. describes a POSIX feature group, then add boilerplate code to
  130. __BOOST_CONFIG_SUFFIX_HEADER__ to auto-detect the feature where possible
  131. (if you are wondering why we can't use POSIX feature test macro directly,
  132. remember that many of these features can be added by third party libraries,
  133. and are not therefore identified inside `<unistd.h>`).
  134. [endsect]
  135. [section Modifying the Boost Configuration Headers]
  136. The aim of boost's configuration setup is that the configuration headers should
  137. be relatively stable - a boost user should not have to recompile their code
  138. just because the configuration for some compiler that they're not interested
  139. in has changed. Separating the configuration into separate compiler/standard
  140. library/platform sections provides for part of this stability, but boost
  141. authors require some amount of restraint as well, in particular:
  142. __BOOST_CONFIG_HEADER__ should never change, don't alter this file.
  143. __BOOST_CONFIG_USER_HEADER__ is included by default, don't add extra code to
  144. this file unless you have to. If you do, please remember to update
  145. [@../../tools/configure.in libs/config/tools/configure.in] as well.
  146. __BOOST_CONFIG_SUFFIX_HEADER__ is always included so be careful about
  147. modifying this file as it breaks dependencies for everyone. This file should
  148. include only "boilerplate" configuration code, and generally should change
  149. only when new macros are added.
  150. [@../../../../boost/config/detail/select_compiler_config.hpp <boost/config/detail/select_compiler_config.hpp>],
  151. [@../../../../boost/config/detail/select_platform_config.hpp <boost/config/detail/select_platform_config.hpp>] and
  152. [@../../../../boost/config/detail/select_stdlib_config.hpp <boost/config/detail/select_stdlib_config.hpp>]
  153. are included by default and should change only if support for a new
  154. compiler/standard library/platform is added.
  155. The compiler/platform/standard library selection code is set up so that unknown
  156. platforms are ignored and assumed to be fully standards compliant - this gives
  157. unknown platforms a "sporting chance" of working "as is" even without running
  158. the configure script.
  159. When adding or modifying the individual mini-configs, assume that future, as
  160. yet unreleased versions of compilers, have all the defects of the current
  161. version. Although this is perhaps unnecessarily pessimistic, it cuts down on
  162. the maintenance of these files, and experience suggests that pessimism is
  163. better placed than optimism here!
  164. [endsect]
  165. [endsect]