📄 guidelines.qbk
字号:
[/ Boost.Config Copyright (c) 2001 Beman Dawes Copyright (c) 2001 Vesa Karvonen Copyright (c) 2001 John Maddock Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)][section Guidelines for Boost Authors]The __BOOST_CONFIG_HEADER__ header is used to pass configuration informationto other boost files, allowing them to cope with platform dependencies suchas arithmetic byte ordering, compiler pragmas, or compiler shortcomings.Without such configuration information, many current compilers would not workwith the Boost libraries.Centralizing configuration information in this header reduces the number offiles that must be modified when porting libraries to new platforms, or whencompilers are updated. Ideally, no other files would have to be modified whenporting to a new platform.Configuration headers are controversial because some view them as condoningbroken compilers and encouraging non-standard subsets. Adding settings foradditional platforms and maintaining existing settings can also be a problem.In other words, configuration headers are a necessary evil rather than adesirable feature. The boost config.hpp policy is designed to minimize theproblems and maximize the benefits of a configuration header.Note that:* Boost library implementers are not required to "`#include <boost/config.hpp>`",and are not required in any way to support compilers that do not complywith the C++ Standard (ISO/IEC 14882). * If a library implementer wishes to support some non-conforming compiler,or to support some platform specific feature, "`#include <boost/config.hpp>`"is the preferred way to obtain configuration information not available fromthe standard headers such as `<climits>`, etc.* If configuration information can be deduced from standard headers such as`<climits>`, use those standard headers rather than `<boost/config.hpp>`.* Boost files that use macros defined in `<boost/config.hpp>` should havesensible, standard conforming, default behavior if the macro is not defined.This means that the starting point for porting `<boost/config.hpp>` to a newplatform is simply to define nothing at all specific to that platform. Inthe rare case where there is no sensible default behavior, an #error messageshould describe the problem.* If a Boost library implementer wants something added to `config.hpp`, posta request on the Boost mailing list. There is no guarantee such a requestwill be honored; the intent is to limit the complexity of config.hpp.* The intent is to support only compilers which appear on their way tobecoming C++ Standard compliant, and only recent releases of those compilersat that.* The intent is not to disable mainstream features now well-supported by themajority of compilers, such as namespaces, exceptions, RTTI, or templates.[section:warnings Disabling Compiler Warnings]The header `<boost/config/warning_disable.hpp>` can be used to disablecertain compiler warings that are hard or impossible to otherwise remove.Note that:* This header [*['should never be included by another Boost header]], it shouldonly ever be used by a library source file or a test case.* The header should be included [*['before you include any other header]].* This header only disables warnings that are hard or impossible to otherwise deal with, and which are typically emitted by one compiler only, or in one compilers own standard library headers. Currently it disables the following warnings:[table[[Compiler][Warning]][[Visual C++ 8 and later][[@http://msdn2.microsoft.com/en-us/library/ttcz0bys(VS.80).aspx C4996]: Error 'function': was declared deprecated]][[Intel C++][Warning 1786: relates to the use of "deprecated" standard library functions rather like C4996 in Visual C++.]]][endsect][section Adding New Defect Macros]When you need to add a new defect macro - either to fix a problem with anexisting library, or when adding a new library - distil the issue down toa simple test case; often, at this point other (possibly better) workaroundsmay become apparent. Secondly always post the test case code to the boostmailing list and invite comments; remember that C++ is complex and thatsometimes what may appear a defect, may in fact turn out to be a problemwith the authors understanding of the standard.When you name the macro, follow the `BOOST_NO_`['SOMETHING] namingconvention, so that it's obvious that this is a macro reporting a defect.Finally, add the test program to the regression tests. You will need toplace the test case in a `.ipp` file with the following comments near the top: // MACRO: BOOST_NO_FOO // TITLE: foo // DESCRIPTION: If the compiler fails to support fooThese comments are processed by the autoconf script, so make sure the formatfollows the one given. The file should be named "`boost_no_foo.ipp`", where foois the defect description - try and keep the file name under the Mac 30 characterfilename limit though. You will also need to provide a function prototype"`int test()`" that is declared in a namespace with the same name as the macro,but in all lower case, and which returns zero on success: namespace boost_no_foo { int test() { // test code goes here: // return 0; } }Once the test code is in place in libs/config/test, updating the configurationtest system proceeds as:* cd into `libs/config/tools` and run `bjam` : this generates the `.cpp`file test cases from the `.ipp` file, updates the libs/config/test/all/Jamfile.v2, `config_test.cpp` and `config_info.cpp`.* cd into `libs/config/test/all` and run `bjam `['MACRONAME` compiler-list`] : where['MACRONAME] is the name of the new macro, and ['`compiler-list`] is a space separated list ofcompilers to test with. You should see the tests pass with those compilersthat don't have the defect, and fail with those that do.* cd into `libs/config/test` and run `bjam config_info config_test `['`compiler-list`] :`config_info` should build and run cleanly for all the compilers in ['`compiler-list`]while `config_test` should fail for those that have the defect, and pass for thosethat do not.Then you should:* Define the defect macro in those config headers that require it.* Document the macro in this documentation (please do not forget this step!!)* Commit everything.* Keep an eye on the regression tests for new failures in Boost.Config caused bythe addition.* Start using the macro.[endsect][section Adding New Feature Test Macros]When you need to add a macro that describes a feature that the standard doesnot require, follow the convention for adding a new defect macro (above), butcall the macro `BOOST_HAS_FOO`, and name the test file "`boost_has_foo.ipp`".Try not to add feature test macros unnecessarily, if there is a platformspecific macro that can already be used (for example `_WIN32`, `__BEOS__`, or`__linux`) to identify the feature then use that. Try to keep the macro to afeature group, or header name, rather than one specific API (for example`BOOST_HAS_NL_TYPES_H` rather than `BOOST_HAS_CATOPEN`). If the macrodescribes a POSIX feature group, then add boilerplate code to__BOOST_CONFIG_SUFFIX_HEADER__ to auto-detect the feature where possible(if you are wondering why we can't use POSIX feature test macro directly,remember that many of these features can be added by third party libraries,and are not therefore identified inside `<unistd.h>`).[endsect][section Modifying the Boost Configuration Headers]The aim of boost's configuration setup is that the configuration headers shouldbe relatively stable - a boost user should not have to recompile their codejust because the configuration for some compiler that they're not interestedin has changed. Separating the configuration into separate compiler/standardlibrary/platform sections provides for part of this stability, but boostauthors require some amount of restraint as well, in particular:__BOOST_CONFIG_HEADER__ should never change, don't alter this file.__BOOST_CONFIG_USER_HEADER__ is included by default, don't add extra code tothis file unless you have to. If you do, please remember to update[@../../tools/configure.in libs/config/tools/configure.in] as well.__BOOST_CONFIG_SUFFIX_HEADER__ is always included so be careful aboutmodifying this file as it breaks dependencies for everyone. This file shouldinclude only "boilerplate" configuration code, and generally should changeonly when new macros are added.[@../../../../boost/config/select_compiler_config.hpp <boost/config/select_compiler_config.hpp>],[@../../../../boost/config/select_platform_config.hpp <boost/config/select_platform_config.hpp>] and[@../../../../boost/config/select_stdlib_config.hpp <boost/config/select_stdlib_config.hpp>]are included by default and should change only if support for a newcompiler/standard library/platform is added.The compiler/platform/standard library selection code is set up so that unknownplatforms are ignored and assumed to be fully standards compliant - this givesunknown platforms a "sporting chance" of working "as is" even without runningthe configure script.When adding or modifying the individual mini-configs, assume that future, asyet unreleased versions of compilers, have all the defects of the currentversion. Although this is perhaps unnecessarily pessimistic, it cuts down onthe maintenance of these files, and experience suggests that pessimism isbetter placed than optimism here![endsect][endsect]
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -