1 | <html> |
---|
2 | <head> |
---|
3 | <title></title> |
---|
4 | <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> |
---|
5 | <meta name="Template" content="C:\PROGRAM FILES\MICROSOFT OFFICE\OFFICE\html.dot"> |
---|
6 | <meta name="GENERATOR" content="Microsoft FrontPage 5.0"> |
---|
7 | </head> |
---|
8 | <body bgcolor="#ffffff" link="#0000ff" vlink="#800080"> |
---|
9 | <p align="left"><img src="../../boost.png" alt="Boost" width="277" height="86"></p> |
---|
10 | <h1 align="center">Boost Configuration Reference</h1> |
---|
11 | <h2>Contents</h2> |
---|
12 | <pre><a href="#configuring">Configuring Boost for Your Platform</a> |
---|
13 | <a href="#default_config">Using the default boost configuration |
---|
14 | </a> <a href="#header">The <boost/config.hpp> header</a> |
---|
15 | <a href="#config_script">Using the configure script</a> |
---|
16 | <a href="#user_settable">User settable options</a> |
---|
17 | <a href="#advanced_config">Advanced configuration usage</a> |
---|
18 | <a href="#testing">Testing the boost configuration</a> |
---|
19 | <a href="#macro_ref">Boost Macro Reference</a> |
---|
20 | <a href="#defects">Macros that describe defects</a> |
---|
21 | <a href="#features">Macros that describe optional features</a> |
---|
22 | <a href="#helpers">Boost Helper Macros</a> |
---|
23 | <a href="#info_macros">Boost Informational Macros</a> |
---|
24 | <a href="#source">Macros for libraries with separate source code</a> |
---|
25 | <a href="#guidelines">Guidelines for Boost Authors</a> |
---|
26 | <a href="#defect_guidelines">Adding New Defect Macros</a> |
---|
27 | <a href="#feature_guidelines">Adding New Feature Test Macros</a> |
---|
28 | <a href="#modify_guidelines">Modifying the Boost Configuration Headers</a> |
---|
29 | <a href="#rationale">Rationale</a> |
---|
30 | <a href="#Acknowledgements">Acknowledgements</a></pre> |
---|
31 | <h2><a name="configuring"></a>Configuring Boost for Your Platform</h2> |
---|
32 | <h4><a name="default_config"></a>Using the default boost configuration</h4> |
---|
33 | <p>Boost comes already configured for most common compilers and platforms; you |
---|
34 | should be able to use boost "as is". Since the compiler is configured |
---|
35 | separately from the standard library, the default configuration should work |
---|
36 | even if you replace the compiler's standard library with a third-party standard |
---|
37 | library (like <a href="http://www.stlport.org">STLport</a>). |
---|
38 | </p> |
---|
39 | <p>Using boost "as is" without trying to reconfigure is the recommended method for |
---|
40 | using boost. You can, however, run the configure script if you want to, and |
---|
41 | there are regression tests provided that allow you to test the current boost |
---|
42 | configuration with your particular compiler setup.</p> |
---|
43 | <p>Boost library users can request support for additional compilers or platforms |
---|
44 | by visiting our <a href="http://sourceforge.net/tracker/?group_id=7586">Tracker</a> |
---|
45 | and submitting a support request. |
---|
46 | </p> |
---|
47 | <h4>The <a href="../../boost/config.hpp"><boost/config.hpp></a> <a name="header"> |
---|
48 | header</a></h4> |
---|
49 | <p>Boost library implementations access configuration macros via <code>#include |
---|
50 | <boost/config.hpp></code>. |
---|
51 | </p> |
---|
52 | <P>While Boost library users are not required to include that file directly, or |
---|
53 | use those configuration macros, such use is acceptable. The configuration |
---|
54 | macros are documented as to their purpose, usage, and limitations which makes |
---|
55 | them usable by both Boost library and user code. |
---|
56 | </P> |
---|
57 | <P>Boost <A href="#info_macros">informational</A> or <A href="#helpers">helper</A> |
---|
58 | macros are designed for use by Boost users as well as for our own internal |
---|
59 | use. Note however, that the <A href="#features">feature test</A> and <A href="#defects"> |
---|
60 | defect test</A> macros were designed for internal use by Boost libraries, |
---|
61 | not user code, so they can change at any time (though no gratuitous changes are |
---|
62 | made to them). Boost library problems resulting from changes to the |
---|
63 | configuration macros are caught by the Boost regression tests, so the Boost |
---|
64 | libraries are updated to account for those changes. By contrast, Boost library |
---|
65 | user code can be adversely affected by changes to the macros without warning. |
---|
66 | The best way to keep abreast of changes to the macros used in user code is to |
---|
67 | monitor the discussions on the Boost developers list.</P> |
---|
68 | <h4><a name="config_script">Using the configure script</a></h4> |
---|
69 | <p>If you know that boost is incorrectly configured for your particular setup, and |
---|
70 | you are on a UNIX like platform, then you may want to try and improve things by |
---|
71 | running the boost configure script. From a shell command prompt you will need |
---|
72 | to cd into <boost-root>/libs/config/ and type:</p> |
---|
73 | <pre>sh ./configure</pre> |
---|
74 | <p>you will see a list of the items being checked as the script works its way |
---|
75 | through the regression tests. Note that the configure script only really |
---|
76 | auto-detects your compiler if it's called g++, c++ or CC. If you are using some |
---|
77 | other compiler you will need to set one or more of the following |
---|
78 | environment variables:</p> |
---|
79 | <table border="1" cellpadding="7" cellspacing="1" width="624"> |
---|
80 | <tr> |
---|
81 | <td valign="top" width="50%"><p align="center"><b>Variable</b></p> |
---|
82 | </td> |
---|
83 | <td valign="top" width="50%"><p align="center"><b>Description</b></p> |
---|
84 | </td> |
---|
85 | </tr> |
---|
86 | <tr> |
---|
87 | <td valign="top" width="50%">CXX</td> |
---|
88 | <td valign="top" width="50%">The name of the compiler, for example "c++".</td> |
---|
89 | </tr> |
---|
90 | <tr> |
---|
91 | <td valign="top" width="50%">CXXFLAGS</td> |
---|
92 | <td valign="top" width="50%">The compiler flags to use, for example "-O2".</td> |
---|
93 | </tr> |
---|
94 | <tr> |
---|
95 | <td valign="top" width="50%">LDFLAGS</td> |
---|
96 | <td valign="top" width="50%">The linker flags to use, for example "-L/mypath".</td> |
---|
97 | </tr> |
---|
98 | <tr> |
---|
99 | <td valign="top" width="50%">LIBS</td> |
---|
100 | <td valign="top" width="50%">Any libraries to link in, for example -lpthread.</td> |
---|
101 | </tr> |
---|
102 | </table> |
---|
103 | <p>For example to run the configure script with HP aCC, you might use something |
---|
104 | like:</p> |
---|
105 | <pre>export CXX="aCC" |
---|
106 | export CXXFLAGS="-Aa -DAportable -D__HPACC_THREAD_SAFE_RB_TREE -DRWSTD_MULTI_THREAD -DRW_MULTI_THREAD -D_REENTRANT -D_THREAD_SAFE" |
---|
107 | export LDFLAGS="-DAportable" |
---|
108 | export LIBS="-lpthread" |
---|
109 | sh ./configure</pre> |
---|
110 | <p>However you run the configure script, when it finishes you will find a new |
---|
111 | header - user.hpp - located in the <boost-root/libs/config/> directory. <b><i>Note |
---|
112 | that configure does not install this header into your boost include path by |
---|
113 | default.</i></b> This header contains all the options generated by the |
---|
114 | configure script, plus a header-section that contains the user settable options |
---|
115 | from the default version of <a href="../../boost/config/user.hpp">user.hpp</a> (located |
---|
116 | under <boost-root>/boost/config/). There are two ways you can use this |
---|
117 | header:</p> |
---|
118 | <p>Option 1: copy the header into <boost-root>/boost/config/ so that it |
---|
119 | replaces the default <a href="../../boost/config/user.hpp">user.hpp</a> provided |
---|
120 | by boost. This option allows only one configure-generated setup; boost |
---|
121 | developers should avoid this option, as it incurs the danger of accidentally |
---|
122 | committing a configure-modified user.hpp to the cvs repository (something you |
---|
123 | will not be thanked for!).</p> |
---|
124 | <p>Option 2: give the header a more memorable name, and place it somewhere |
---|
125 | convenient; then, define the macro BOOST_USER_CONFIG to point to it. For example |
---|
126 | create a new sub-directory <boost-root>/boost/config/user/, and copy the |
---|
127 | header there; for example as "multithread-gcc-config.hpp". Then, when compiling |
---|
128 | add the command line option: |
---|
129 | -DBOOST_USER_CONFIG="<boost/config/user/multithread-gcc-config.hpp>", and boost |
---|
130 | will use the new configuration header. This option allows you to generate more |
---|
131 | than one configuration header, and to keep them separate from the boost source |
---|
132 | - so that updates to the source do not interfere with your configuration.</p> |
---|
133 | <h4><a name="user_settable"></a>User settable options</h4> |
---|
134 | <p>There are some configuration-options that represent user choices, rather than |
---|
135 | compiler defects or platform specific options. These are listed in |
---|
136 | <boost/config/user.hpp> and at the start of a configure-generated |
---|
137 | user.hpp header. You can define these on the command line, or by editing |
---|
138 | <boost/config/user.hpp>, they are listed in the following table: </p> |
---|
139 | <table border="1" cellpadding="7" cellspacing="1" width="100%"> |
---|
140 | <tr> |
---|
141 | <td valign="top" width="48%"><p align="center"><b>Macro</b></p> |
---|
142 | </td> |
---|
143 | <td valign="top" width="52%"><p align="center"><b>Description</b></p> |
---|
144 | </td> |
---|
145 | </tr> |
---|
146 | <tr> |
---|
147 | <td valign="top" width="48%">BOOST_USER_CONFIG</td> |
---|
148 | <td valign="top" width="52%">When defined, it should point to the name of the user |
---|
149 | configuration file to include prior to any boost configuration files. When not |
---|
150 | defined, defaults to <<a href="../../boost/config/user.hpp">boost/config/user.hpp</a>>.</td> |
---|
151 | </tr> |
---|
152 | <tr> |
---|
153 | <td valign="top" width="48%">BOOST_COMPILER_CONFIG</td> |
---|
154 | <td valign="top" width="52%">When defined, it should point to the name of the |
---|
155 | compiler configuration file to use. Defining this cuts out the compiler |
---|
156 | selection logic, and eliminates the dependency on the header containing that |
---|
157 | logic. For example if you are using gcc, then you could define |
---|
158 | BOOST_COMPILER_CONFIG to "<a href="../../boost/config/compiler/gcc.hpp">boost/config/compiler/gcc.hpp</a>".</td> |
---|
159 | </tr> |
---|
160 | <tr> |
---|
161 | <td valign="top" width="48%">BOOST_STDLIB_CONFIG</td> |
---|
162 | <td valign="top" width="52%">When defined, it should point to the name of the |
---|
163 | standard library configuration file to use. Defining this cuts out the standard |
---|
164 | library selection logic, and eliminates the dependency on the header containing |
---|
165 | that logic. For example if you are using STLport, then you could define |
---|
166 | BOOST_STDLIB_CONFIG to "<a href="../../boost/config/stdlib/stlport.hpp">boost/config/stdlib/stlport.hpp</a>".</td> |
---|
167 | </tr> |
---|
168 | <tr> |
---|
169 | <td valign="top" width="48%">BOOST_PLATFORM_CONFIG</td> |
---|
170 | <td valign="top" width="52%">When defined, it should point to the name of the |
---|
171 | platform configuration file to use. Defining this cuts out the platform |
---|
172 | selection logic, and eliminates the dependency on the header containing that |
---|
173 | logic. For example if you are compiling on linux, then you could define |
---|
174 | BOOST_PLATFORM_CONFIG to "<a href="../../boost/config/platform/linux.hpp">boost/config/platform/linux.hpp</a>".</td> |
---|
175 | </tr> |
---|
176 | <tr> |
---|
177 | <td valign="top" width="48%">BOOST_NO_COMPILER_CONFIG</td> |
---|
178 | <td valign="top" width="52%">When defined, no compiler configuration file is |
---|
179 | selected or included, define when the compiler is fully conformant with the |
---|
180 | standard, or where the user header (see BOOST_USER_CONFIG), has had any options |
---|
181 | necessary added to it, for example by an autoconf generated configure script.</td> |
---|
182 | </tr> |
---|
183 | <tr> |
---|
184 | <td valign="top" width="48%">BOOST_NO_STDLIB_CONFIG</td> |
---|
185 | <td valign="top" width="52%">When defined, no standard library configuration file |
---|
186 | is selected or included, define when the standard library is fully conformant |
---|
187 | with the standard, or where the user header (see BOOST_USER_CONFIG), has had |
---|
188 | any options necessary added to it, for example by an autoconf generated |
---|
189 | configure script.</td> |
---|
190 | </tr> |
---|
191 | <tr> |
---|
192 | <td valign="top" width="48%">BOOST_NO_PLATFORM_CONFIG</td> |
---|
193 | <td valign="top" width="52%">When defined, no platform configuration file is |
---|
194 | selected or included, define when the platform is fully conformant with the |
---|
195 | standard (and has no useful extra features), or where the user header (see |
---|
196 | BOOST_USER_CONFIG), has had any options necessary added to it, for example by |
---|
197 | an autoconf generated configure script.</td> |
---|
198 | </tr> |
---|
199 | <tr> |
---|
200 | <td valign="top" width="48%">BOOST_NO_CONFIG</td> |
---|
201 | <td valign="top" width="52%">Equivalent to defining all of |
---|
202 | BOOST_NO_COMPILER_CONFIG, BOOST_NO_STDLIB_CONFIG and BOOST_NO_PLATFORM_CONFIG.</td> |
---|
203 | </tr> |
---|
204 | <tr> |
---|
205 | <td valign="top">BOOST_STRICT_CONFIG</td> |
---|
206 | <td>The normal behavior for compiler versions that are newer than the last known |
---|
207 | version, is to assume that they have all the same defects as the last known |
---|
208 | version. By setting this define, then compiler versions that are newer than the |
---|
209 | last known version are assumed to be fully conforming with the standard. This |
---|
210 | is probably most useful for boost developers or testers, and for those who want |
---|
211 | to use boost to test beta compiler versions.</td> |
---|
212 | </tr> |
---|
213 | <tr> |
---|
214 | <td valign="top">BOOST_ASSERT_CONFIG</td> |
---|
215 | <td>When this flag is set, if the config finds anything unknown, then it will stop |
---|
216 | with a #error rather than continue. Boost regression testers should set this |
---|
217 | define, as should anyone who wants to quickly check whether boost is supported |
---|
218 | on their platform.</td> |
---|
219 | </tr> |
---|
220 | <tr> |
---|
221 | <td valign="top" width="48%">BOOST_DISABLE_THREADS</td> |
---|
222 | <td valign="top" width="52%">When defined, disables threading support, even if the |
---|
223 | compiler in its current translation mode supports multiple threads.</td> |
---|
224 | </tr> |
---|
225 | <tr> |
---|
226 | <td valign="top">BOOST_DISABLE_WIN32</td> |
---|
227 | <td>When defined, disables the use of Win32 specific API's, even when these are |
---|
228 | available. Also has the effect of setting BOOST_DISABLE_THREADS unless |
---|
229 | BOOST_HAS_PTHREADS is set. This option may be set automatically by the config |
---|
230 | system when it detects that the compiler is in "strict mode".</td> |
---|
231 | </tr> |
---|
232 | <TR> |
---|
233 | <TD vAlign="top">BOOST_DISABLE_ABI_HEADERS</TD> |
---|
234 | <TD>Stops boost headers from including any prefix/suffix headers that normally |
---|
235 | control things like struct packing and alignment.</TD> |
---|
236 | </TR> |
---|
237 | <TR> |
---|
238 | <TD vAlign="top">BOOST_ABI_PREFIX</TD> |
---|
239 | <TD>A prefix header to include in place of whatever boost.config would normally |
---|
240 | select, any replacement should set up struct packing and alignment options as |
---|
241 | required.</TD> |
---|
242 | </TR> |
---|
243 | <TR> |
---|
244 | <TD vAlign="top">BOOST_ABI_SUFFIX</TD> |
---|
245 | <TD>A suffix header to include in place of whatever boost.config would normally |
---|
246 | select, any replacement should undo the effects of the prefix header.</TD> |
---|
247 | </TR> |
---|
248 | <TR> |
---|
249 | <TD vAlign="top">BOOST_ALL_DYN_LINK</TD> |
---|
250 | <TD> |
---|
251 | <P>Forces all libraries that have separate source, to be linked as dll's rather |
---|
252 | than static libraries on Microsoft Windows (this macro is used to turn on |
---|
253 | __declspec(dllimport) modifiers, so that the compiler knows which symbols to |
---|
254 | look for in a dll rather than in a static library). |
---|
255 | </P> |
---|
256 | <P>Note that there may be some libraries that can only be statically linked |
---|
257 | (Boost.Test for example) and others which may only be dynamically linked |
---|
258 | (Boost.Threads for example), in these cases this macro has no effect.</P> |
---|
259 | </TD> |
---|
260 | </TR> |
---|
261 | <TR> |
---|
262 | <TD vAlign="top">BOOST_WHATEVER_DYN_LINK</TD> |
---|
263 | <TD> |
---|
264 | <P>Forces library "whatever" to be linked as a dll rather than a static library on |
---|
265 | Microsoft Windows: replace the WHATEVER part of the macro name with the name of |
---|
266 | the library that you want to dynamically link to, for example use |
---|
267 | BOOST_DATE_TIME_DYN_LINK or BOOST_REGEX_DYN_LINK etc (this macro is used |
---|
268 | to turn on __declspec(dllimport) modifiers, so that the compiler knows which |
---|
269 | symbols to look for in a dll rather than in a static library). |
---|
270 | </P> |
---|
271 | <P>Note that there may be some libraries that can only be statically linked |
---|
272 | (Boost.Test for example) and others which may only be dynamically linked |
---|
273 | (Boost.Threads for example), in these cases this macro is unsupported.</P> |
---|
274 | </TD> |
---|
275 | </TR> |
---|
276 | <TR> |
---|
277 | <TD vAlign="top">BOOST_ALL_NO_LIB</TD> |
---|
278 | <TD> |
---|
279 | <P>Tells the config system not to automatically select which libraries to link |
---|
280 | against. |
---|
281 | </P> |
---|
282 | <P>Normally if a compiler supports #pragma lib, then the correct library build |
---|
283 | variant will be automatically selected and linked against, simply by the act of |
---|
284 | including one of that library's headers. This macro turns that feature |
---|
285 | off.</P> |
---|
286 | </TD> |
---|
287 | </TR> |
---|
288 | <TR> |
---|
289 | <TD vAlign="top">BOOST_WHATEVER_NO_LIB</TD> |
---|
290 | <TD> |
---|
291 | <P>Tells the config system not to automatically select which library to link |
---|
292 | against for library "whatever", replace WHATEVER in the macro name with the |
---|
293 | name of the library; for example BOOST_DATE_TIME_NO_LIB or |
---|
294 | BOOST_REGEX_NO_LIB. |
---|
295 | </P> |
---|
296 | <P>Normally if a compiler supports #pragma lib, then the correct library build |
---|
297 | variant will be automatically selected and linked against, simply by the act of |
---|
298 | including one of that library's headers. This macro turns that feature |
---|
299 | off.</P> |
---|
300 | </TD> |
---|
301 | </TR> |
---|
302 | <TR> |
---|
303 | <TD vAlign="top">BOOST_LIB_DIAGNOSTIC</TD> |
---|
304 | <TD>Causes the auto-linking code to output diagnostic messages indicating the name |
---|
305 | of the library that is selected for linking.</TD> |
---|
306 | </TR> |
---|
307 | <TR> |
---|
308 | <TD vAlign="top">BOOST_LIB_TOOLSET</TD> |
---|
309 | <TD>Overrides the name of the toolset part of the name of library being linked to; |
---|
310 | note if defined this must be defined to a quoted string literal, for example |
---|
311 | "abc".</TD> |
---|
312 | </TR> |
---|
313 | </table> |
---|
314 | <h4><a name="advanced_config"></a>Advanced configuration usage</h4> |
---|
315 | <p>By setting various macros on the compiler command line or by editing <<a href="../../boost/config/user.hpp">boost/config/user.hpp</a>>, |
---|
316 | the boost configuration setup can be optimised in a variety of ways. |
---|
317 | </p> |
---|
318 | <p>Boost's configuration is structured so that the user-configuration is included |
---|
319 | first (defaulting to <<a href="../../boost/config/user.hpp">boost/config/user.hpp</a>> |
---|
320 | if BOOST_USER_CONFIG is not defined). This sets up any user-defined policies, |
---|
321 | and gives the user-configuration a chance to influence what happens next. |
---|
322 | </p> |
---|
323 | <p>Next the compiler, standard library, and platform configuration files are |
---|
324 | included. These are included via macros (BOOST_COMPILER_CONFIG etc, <a href="#user_settable"> |
---|
325 | see user settable macros</a>), and if the corresponding macro is undefined |
---|
326 | then a separate header that detects which compiler/standard library/platform is |
---|
327 | in use is included in order to set these. The config can be told to ignore |
---|
328 | these headers altogether if the corresponding BOOST_NO_XXX macro is set (for |
---|
329 | example BOOST_NO_COMPILER_CONFIG to disable including any compiler |
---|
330 | configuration file - <a href="#user_settable">see user settable macros</a>). |
---|
331 | </p> |
---|
332 | <p>Finally the boost configuration header, includes <<a href="../../boost/config/suffix.hpp">boost/config/suffix.hpp</a>>; |
---|
333 | this header contains any boiler plate configuration code - for example where |
---|
334 | one boost macro being set implies that another must be set also.</p> |
---|
335 | <p>The following usage examples represent just a few of the possibilities:</p> |
---|
336 | <p><u>Example 1, creating our own frozen configuration.</u></p> |
---|
337 | <p>Lets suppose that we're building boost with Visual C++ 6, and STLport 4.0. Lets |
---|
338 | suppose also that we don't intend to update our compiler or standard library |
---|
339 | any time soon. In order to avoid breaking dependencies when we update boost, we |
---|
340 | may want to "freeze" our configuration headers, so that we only have to rebuild |
---|
341 | our project if the boost code itself has changed, and not because the boost |
---|
342 | config has been updated for more recent versions of Visual C++ or STLport. |
---|
343 | We'll start by realising that the configuration files in use are: <<a href="../../boost/config/compiler/visualc.hpp">boost/config/compiler/visualc.hpp</a>> |
---|
344 | for the compiler, <<a href="../../boost/config/stdlib/stlport.hpp">boost/config/stdlib/stlport.hpp</a>> |
---|
345 | for the standard library, and <<a href="../../boost/config/platform/win32.hpp">boost/config/platform/win32.hpp</a>> |
---|
346 | for the platform. Next we'll create our own private configuration directory: |
---|
347 | boost/config/mysetup/, and copy the configuration files into there. Finally, |
---|
348 | open up <<a href="../../boost/config/user.hpp">boost/config/user.hpp</a>> |
---|
349 | and edit the following defines:</p> |
---|
350 | <pre>#define BOOST_COMPILER_CONFIG "boost/config/mysetup/visualc.hpp" |
---|
351 | #define BOOST_STDLIB_CONFIG "boost/config/mysetup/stlport.hpp" |
---|
352 | #define BOOST_USER_CONFIG "boost/config/mysetup/win32.hpp"</pre> |
---|
353 | <p>Now when you use boost, its configuration header will go straight to our |
---|
354 | "frozen" versions, and ignore the default versions, you will now be insulated |
---|
355 | from any configuration changes when you update boost. This technique is also |
---|
356 | useful if you want to modify some of the boost configuration files; for example |
---|
357 | if you are working with a beta compiler release not yet supported by boost.</p> |
---|
358 | <p><u>Example 2: skipping files that you don't need.</u></p> |
---|
359 | <p>Lets suppose that you're using boost with a compiler that is fully conformant |
---|
360 | with the standard; you're not interested in the fact that older versions of |
---|
361 | your compiler may have had bugs, because you know that your current version |
---|
362 | does not need any configuration macros setting. In a case like this, you can |
---|
363 | define BOOST_NO_COMPILER_CONFIG either on the command line, or in |
---|
364 | <boost/config/user.hpp>, and miss out the compiler configuration header |
---|
365 | altogether (actually you miss out two headers, one which works out what the |
---|
366 | compiler is, and one that configures boost for it). This has two consequences: |
---|
367 | the first is that less code has to be compiled, and the second that you have |
---|
368 | removed a dependency on two boost headers.</p> |
---|
369 | <p><u>Example 3: using configure script to freeze the boost configuration.</u></p> |
---|
370 | <p>If you are working on a unix-like platform then you can use the configure |
---|
371 | script to generate a "frozen" configuration based on your current compiler |
---|
372 | setup - <a href="#config_script">see using the configure script</a> for more |
---|
373 | details.</p> |
---|
374 | <h4><a name="testing"></a>Testing the boost configuration</h4> |
---|
375 | <p>The boost configuration library provides a full set of regression test programs |
---|
376 | under the <boost-root>/libs/config/test/ sub-directory:</p> |
---|
377 | <table border="1" cellpadding="7" cellspacing="1" width="100%"> |
---|
378 | <tr> |
---|
379 | <td valign="top" width="50%"><p align="center"><b>File</b></p> |
---|
380 | </td> |
---|
381 | <td valign="top" width="50%"><p align="center"><b>Description</b></p> |
---|
382 | </td> |
---|
383 | </tr> |
---|
384 | <tr> |
---|
385 | <td valign="top" width="50%">config_info.cpp</td> |
---|
386 | <td valign="top" width="50%">Prints out a detailed description of your |
---|
387 | compiler/standard library/platform setup, plus your current boost |
---|
388 | configuration. The information provided by this program useful in setting up |
---|
389 | the boost configuration files. If you report that boost is incorrectly |
---|
390 | configured for your compiler/library/platform then please include the output |
---|
391 | from this program when reporting the changes required.</td> |
---|
392 | </tr> |
---|
393 | <tr> |
---|
394 | <td valign="top" width="50%">config_test.cpp</td> |
---|
395 | <td valign="top" width="50%">A monolithic test program that includes most of the |
---|
396 | individual test cases. This provides a quick check to see if boost is correctly |
---|
397 | configured for your compiler/library/platform.</td> |
---|
398 | </tr> |
---|
399 | <tr> |
---|
400 | <td valign="top" width="50%">limits_test.cpp</td> |
---|
401 | <td valign="top" width="50%">Tests your standard library's std::numeric_limits |
---|
402 | implementation (or its boost provided replacement if BOOST_NO_LIMITS is |
---|
403 | defined). This test file fails with most versions of numeric_limits, mainly due |
---|
404 | to the way that some compilers treat NAN's and infinity.</td> |
---|
405 | </tr> |
---|
406 | <tr> |
---|
407 | <td valign="top" width="50%">no_*pass.cpp</td> |
---|
408 | <td valign="top" width="50%">Individual compiler defect test files. Each of these |
---|
409 | should compile, if one does not then the corresponding BOOST_NO_XXX macro needs |
---|
410 | to be defined - see each test file for specific details.</td> |
---|
411 | </tr> |
---|
412 | <tr> |
---|
413 | <td valign="top" width="50%">no_*fail.cpp</td> |
---|
414 | <td valign="top" width="50%">Individual compiler defect test files. Each of these |
---|
415 | should <i>not</i> compile, if one does then the corresponding BOOST_NO_XXX |
---|
416 | macro is defined when it need not be - see each test file for specific details.</td> |
---|
417 | </tr> |
---|
418 | <tr> |
---|
419 | <td valign="top" width="50%">has_*pass.cpp</td> |
---|
420 | <td valign="top" width="50%">Individual feature test files. If one of these does <i>not</i> |
---|
421 | compile then the corresponding BOOST_HAS_XXX macro is defined when it should |
---|
422 | not be - see each test file for specific details.</td> |
---|
423 | </tr> |
---|
424 | <tr> |
---|
425 | <td valign="top" width="50%">has_*fail.cpp</td> |
---|
426 | <td valign="top" width="50%">Individual feature test files. If one of these does |
---|
427 | compile then the corresponding BOOST_HAS_XXX macro can be safely defined - see |
---|
428 | each test file for specific details.</td> |
---|
429 | </tr> |
---|
430 | </table> |
---|
431 | <p>Although you can run the configuration regression tests as individual test |
---|
432 | files, there are rather a lot of them, so there are a couple of shortcuts to |
---|
433 | help you out:</p> |
---|
434 | <p>If you have built the <a href="../../more/regression.html">boost regression test |
---|
435 | driver</a>, then you can use this to produce a nice html formatted report of |
---|
436 | the results using the supplied test file.</p> |
---|
437 | <p>Alternatively you can run the configure script like this:</p> |
---|
438 | <pre>./configure --enable-test</pre> |
---|
439 | <p>in which case the script will test the current configuration rather than |
---|
440 | creating a new one from scratch.</p> |
---|
441 | <p>If you are reporting the results of these tests for a new |
---|
442 | platform/library/compiler then please include a log of the full compiler |
---|
443 | output, the output from config_info.cpp, and the pass/fail test results.</p> |
---|
444 | <h2><a name="macro_ref"></a>Boost Macro Reference</h2> |
---|
445 | <h4><a name="defects"></a>Macros that describe defects:</h4> |
---|
446 | <p>The following macros all describe features that are required by the C++ |
---|
447 | standard, if one of the following macros is defined, then it represents a |
---|
448 | defect in the compiler's conformance with the standard.</p> |
---|
449 | <table border="1" cellpadding="7" cellspacing="1" width="100%"> |
---|
450 | <tr> |
---|
451 | <td valign="top" width="51%"><p align="center"><b>Macro</b></p> |
---|
452 | </td> |
---|
453 | <td valign="top" width="16%"><p align="center"><b>Section</b></p> |
---|
454 | </td> |
---|
455 | <td valign="top" width="33%"><p align="center"><b>Description</b></p> |
---|
456 | </td> |
---|
457 | </tr> |
---|
458 | <tr> |
---|
459 | <td>BOOST_BCB_PARTIAL_SPECIALIZATION_BUG</td> |
---|
460 | <td>Compiler</td> |
---|
461 | <td>The compiler exibits certain partial specialisation bug - probably Borland C++ |
---|
462 | Builder specific.</td> |
---|
463 | </tr> |
---|
464 | <TR> |
---|
465 | <TD vAlign="top" width="51%">BOOST_FUNCTION_SCOPE_USING_DECLARATION_BREAKS_ADL</TD> |
---|
466 | <TD vAlign="top" width="16%">Compiler</TD> |
---|
467 | <TD vAlign="top" width="33%">Argument dependent lookup fails if there is a using |
---|
468 | declaration for the symbol being looked up in the current scope. For |
---|
469 | example, <code>using boost::get_pointer;</code> prevents ADL from finding |
---|
470 | overloads of <code>get_pointer</code> in namespaces nested inside boost (but |
---|
471 | not elsewhere). Probably Borland specific.</TD> |
---|
472 | </TR> |
---|
473 | <tr> |
---|
474 | <td valign="top" width="51%">BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP</td> |
---|
475 | <td valign="top" width="16%">Compiler</td> |
---|
476 | <td valign="top" width="33%">Compiler does not implement argument-dependent lookup |
---|
477 | (also named Koenig lookup); see std::3.4.2 [basic.koenig.lookup]</td> |
---|
478 | </tr> |
---|
479 | <tr> |
---|
480 | <td valign="top" width="51%">BOOST_NO_AUTO_PTR</td> |
---|
481 | <td valign="top" width="16%">Standard library</td> |
---|
482 | <td valign="top" width="33%">If the compiler / library supplies non-standard or |
---|
483 | broken std::auto_ptr.</td> |
---|
484 | </tr> |
---|
485 | <tr> |
---|
486 | <td valign="top" width="51%">BOOST_NO_CTYPE_FUNCTIONS</td> |
---|
487 | <td valign="top" width="16%">Platform</td> |
---|
488 | <td valign="top" width="33%">The Platform does not provide functions for the |
---|
489 | character-classifying operations <ctype.h> and <cctype>, only |
---|
490 | macros.</td> |
---|
491 | </tr> |
---|
492 | <tr> |
---|
493 | <td valign="top" width="51%">BOOST_NO_CV_SPECIALIZATIONS</td> |
---|
494 | <td valign="top" width="16%">Compiler</td> |
---|
495 | <td valign="top" width="33%">If template specialisations for cv-qualified types |
---|
496 | conflict with a specialisation for a cv-unqualififed type.</td> |
---|
497 | </tr> |
---|
498 | <tr> |
---|
499 | <td valign="top" width="51%">BOOST_NO_CV_VOID_SPECIALIZATIONS</td> |
---|
500 | <td valign="top" width="16%">Compiler</td> |
---|
501 | <td valign="top" width="33%">If template specialisations for cv-void types |
---|
502 | conflict with a specialisation for void.</td> |
---|
503 | </tr> |
---|
504 | <tr> |
---|
505 | <td valign="top" width="51%">BOOST_NO_CWCHAR</td> |
---|
506 | <td valign="top" width="16%">Platform</td> |
---|
507 | <td valign="top" width="33%">The Platform does not provide <wchar.h> and |
---|
508 | <cwchar>.</td> |
---|
509 | </tr> |
---|
510 | <tr> |
---|
511 | <td valign="top" width="51%">BOOST_NO_CWCTYPE</td> |
---|
512 | <td valign="top" width="16%">Platform</td> |
---|
513 | <td valign="top" width="33%">The Platform does not provide <wctype.h> and |
---|
514 | <cwctype>.</td> |
---|
515 | </tr> |
---|
516 | <tr> |
---|
517 | <td valign="top" width="51%">BOOST_NO_DEPENDENT_NESTED_DERIVATIONS</td> |
---|
518 | <td valign="top" width="16%">Compiler</td> |
---|
519 | <td valign="top" width="33%">The compiler fails to compile a nested class that has |
---|
520 | a dependent base class:<pre>template<typename T> |
---|
521 | struct foo : { |
---|
522 | template<typename U> |
---|
523 | struct bar : public U {}; |
---|
524 | };</pre> |
---|
525 | </td> |
---|
526 | </tr> |
---|
527 | <tr> |
---|
528 | <td valign="top" width="51%">BOOST_NO_DEPENDENT_TYPES_IN_TEMPLATE_VALUE_PARAMETERS</td> |
---|
529 | <td valign="top" width="16%">Compiler</td> |
---|
530 | <td valign="top" width="33%">Template value parameters cannot have a dependent |
---|
531 | type, for example:<pre>template<class T, typename T::type value> |
---|
532 | class X { ... };</pre> |
---|
533 | </td> |
---|
534 | </tr> |
---|
535 | <tr> |
---|
536 | <td valign="top">BOOST_NO_EXCEPTION_STD_NAMESPACE</td> |
---|
537 | <td valign="top">Standard Library</td> |
---|
538 | <td>The standard library does not put some or all of the contents of |
---|
539 | <exception> in namespace std.</td> |
---|
540 | </tr> |
---|
541 | <tr> |
---|
542 | <td valign="top">BOOST_NO_EXCEPTIONS</td> |
---|
543 | <td valign="top">Compiler</td> |
---|
544 | <td>The compiler does not support exception handling (this setting is typically |
---|
545 | required by many C++ compilers for embedded platforms). Note that there is no |
---|
546 | requirement for boost libraries to honor this configuration setting - indeed |
---|
547 | doing so may be impossible in some cases. Those libraries that do honor this |
---|
548 | will typically abort if a critical error occurs - you have been warned!</td> |
---|
549 | </tr> |
---|
550 | <tr> |
---|
551 | <td valign="top" width="51%">BOOST_NO_EXPLICIT_FUNCTION_TEMPLATE_ARGUMENTS</td> |
---|
552 | <td valign="top" width="16%">Compiler</td> |
---|
553 | <td valign="top" width="33%">Can only use deduced template arguments when calling |
---|
554 | function template instantiations.</td> |
---|
555 | </tr> |
---|
556 | <tr> |
---|
557 | <td valign="top" width="51%">BOOST_NO_FUNCTION_TEMPLATE_ORDERING</td> |
---|
558 | <td valign="top" width="16%">Compiler</td> |
---|
559 | <td valign="top" width="33%">The compiler does not perform function template |
---|
560 | ordering or its function template ordering is incorrect. |
---|
561 | <pre>template<typename T> void f(T); // #1 |
---|
562 | template<typename T, typename U> void f(T (*)(U)); // #2 |
---|
563 | |
---|
564 | void bar(int); |
---|
565 | |
---|
566 | f(&bar); // should choose #2.</pre> |
---|
567 | </td> |
---|
568 | </tr> |
---|
569 | <tr> |
---|
570 | <td valign="top" width="51%">BOOST_NO_INCLASS_MEMBER_INITIALIZATION</td> |
---|
571 | <td valign="top" width="16%">Compiler</td> |
---|
572 | <td valign="top" width="33%">Compiler violates std::9.4.2/4.</td> |
---|
573 | </tr> |
---|
574 | <tr> |
---|
575 | <td valign="top" width="51%">BOOST_NO_INTRINSIC_WCHAR_T</td> |
---|
576 | <td valign="top" width="16%">Compiler</td> |
---|
577 | <td valign="top" width="33%">The C++ implementation does not provide wchar_t, or |
---|
578 | it is really a synonym for another integral type. Use this symbol to decide |
---|
579 | whether it is appropriate to explicitly specialize a template on wchar_t if |
---|
580 | there is already a specialization for other integer types.</td> |
---|
581 | </tr> |
---|
582 | <TR> |
---|
583 | <TD vAlign="top" width="51%">BOOST_NO_IS_ABSTRACT</TD> |
---|
584 | <TD vAlign="top" width="16%">Compiler</TD> |
---|
585 | <TD vAlign="top" width="33%">The C++ compiler does not support SFINAE with |
---|
586 | abstract types, this is covered by <A href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#337"> |
---|
587 | Core Language DR337</A>, but is not part of the current standard. |
---|
588 | Fortunately most compilers that support SFINAE also support this DR.</TD> |
---|
589 | </TR> |
---|
590 | <tr> |
---|
591 | <td valign="top" width="51%">BOOST_NO_LIMITS</td> |
---|
592 | <td valign="top" width="16%">Standard library</td> |
---|
593 | <td valign="top" width="33%">The C++ implementation does not provide the |
---|
594 | <limits> header. Never check for this symbol in library code; always |
---|
595 | include <boost/limits.hpp>, which guarantees to provide <code>std::numeric_limits</code>.</td> |
---|
596 | </tr> |
---|
597 | <tr> |
---|
598 | <td valign="top" width="51%">BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS</td> |
---|
599 | <td valign="top" width="16%">Standard library</td> |
---|
600 | <td valign="top" width="33%">Constants such as numeric_limits<T>::is_signed |
---|
601 | are not available for use at compile-time.</td> |
---|
602 | </tr> |
---|
603 | <tr> |
---|
604 | <td>BOOST_NO_LONG_LONG_NUMERIC_LIMITS</td> |
---|
605 | <td>Standard library</td> |
---|
606 | <td>There is no specialization for numeric_limits<long long> and |
---|
607 | numeric_limits<unsigned long long>. <boost/limits.hpp> will then |
---|
608 | add these specializations as a standard library "fix" only if the compiler |
---|
609 | supports the long long datatype.</td> |
---|
610 | </tr> |
---|
611 | <tr> |
---|
612 | <td>BOOST_NO_MEMBER_FUNCTION_SPECIALIZATIONS</td> |
---|
613 | <td>Compiler</td> |
---|
614 | <td>The compiler does not support the specialization of individual member |
---|
615 | functions of template classes.</td> |
---|
616 | </tr> |
---|
617 | <tr> |
---|
618 | <td valign="top" width="51%">BOOST_NO_MEMBER_TEMPLATE_KEYWORD</td> |
---|
619 | <td valign="top" width="16%">Compiler</td> |
---|
620 | <td valign="top" width="33%">If the compiler supports member templates, but not |
---|
621 | the template keyword when accessing member template classes.</td> |
---|
622 | </tr> |
---|
623 | <tr> |
---|
624 | <td valign="top" width="51%">BOOST_NO_MEMBER_TEMPLATE_FRIENDS</td> |
---|
625 | <td valign="top" width="16%">Compiler</td> |
---|
626 | <td valign="top" width="33%">Member template friend syntax ("template<class |
---|
627 | P> friend class frd;") described in the C++ Standard, 14.5.3, not supported.</td> |
---|
628 | </tr> |
---|
629 | <tr> |
---|
630 | <td valign="top" width="51%">BOOST_NO_MEMBER_TEMPLATES</td> |
---|
631 | <td valign="top" width="16%">Compiler</td> |
---|
632 | <td valign="top" width="33%">Member template functions not fully supported.</td> |
---|
633 | </tr> |
---|
634 | <tr> |
---|
635 | <td>BOOST_NO_MS_INT64_NUMERIC_LIMITS</td> |
---|
636 | <td>Standard library</td> |
---|
637 | <td>There is no specialization for numeric_limits<__int64> and |
---|
638 | numeric_limits<unsigned __int64>. <boost/limits.hpp> will then add |
---|
639 | these specializations as a standard library "fix", only if the compiler |
---|
640 | supports the __int64 datatype.</td> |
---|
641 | </tr> |
---|
642 | <tr> |
---|
643 | <td valign="top" width="51%">BOOST_NO_OPERATORS_IN_NAMESPACE</td> |
---|
644 | <td valign="top" width="16%">Compiler</td> |
---|
645 | <td valign="top" width="33%">Compiler requires inherited operator friend functions |
---|
646 | to be defined at namespace scope, then using'ed to boost. Probably GCC |
---|
647 | specific. See <a href="../../boost/operators.hpp">boost/operators.hpp</a> for |
---|
648 | example.</td> |
---|
649 | </tr> |
---|
650 | <tr> |
---|
651 | <td valign="top" width="51%">BOOST_NO_POINTER_TO_MEMBER_CONST</td> |
---|
652 | <td valign="top" width="16%">Compiler</td> |
---|
653 | <td valign="top" width="33%">The compiler does not correctly handle pointers to |
---|
654 | const member functions, preventing use of these in overloaded function |
---|
655 | templates. See <a href="../../boost/functional.hpp">boost/functional.hpp</a> for |
---|
656 | example.</td> |
---|
657 | </tr> |
---|
658 | <TR> |
---|
659 | <TD vAlign="top" width="51%">BOOST_NO_POINTER_TO_MEMBER_TEMPLATE_PARAMETERS</TD> |
---|
660 | <TD vAlign="top" width="16%">Compiler</TD> |
---|
661 | <TD vAlign="top" width="33%">Pointers to members don't work when used as template |
---|
662 | parameters.</TD> |
---|
663 | </TR> |
---|
664 | <tr> |
---|
665 | <td valign="top" width="51%">BOOST_NO_PRIVATE_IN_AGGREGATE</td> |
---|
666 | <td valign="top" width="16%">Compiler</td> |
---|
667 | <td valign="top" width="33%">The compiler misreads 8.5.1, treating classes as |
---|
668 | non-aggregate if they contain private or protected member functions.</td> |
---|
669 | </tr> |
---|
670 | <TR> |
---|
671 | <TD vAlign="top" width="51%">BOOST_NO_SFINAE</TD> |
---|
672 | <TD vAlign="top" width="16%">Compiler</TD> |
---|
673 | <TD vAlign="top" width="33%">The compiler does not support the "Substitution |
---|
674 | Failure Is Not An Error" meta-programming idiom.</TD> |
---|
675 | </TR> |
---|
676 | <tr> |
---|
677 | <td valign="top" width="51%">BOOST_NO_STD_ALLOCATOR</td> |
---|
678 | <td valign="top" width="16%">Standard library</td> |
---|
679 | <td valign="top" width="33%">The C++ standard library does not provide a standards |
---|
680 | conforming std::allocator.</td> |
---|
681 | </tr> |
---|
682 | <tr> |
---|
683 | <td valign="top" width="51%">BOOST_NO_STD_DISTANCE</td> |
---|
684 | <td valign="top" width="16%">Standard library</td> |
---|
685 | <td valign="top" width="33%">The platform does not have a conforming version of |
---|
686 | std::distance.</td> |
---|
687 | </tr> |
---|
688 | <tr> |
---|
689 | <td valign="top" width="51%">BOOST_NO_STD_ITERATOR</td> |
---|
690 | <td valign="top" width="16%">Standard library</td> |
---|
691 | <td valign="top" width="33%">The C++ implementation fails to provide the |
---|
692 | std::iterator class.</td> |
---|
693 | </tr> |
---|
694 | <tr> |
---|
695 | <td valign="top" width="51%">BOOST_NO_STD_ITERATOR_TRAITS</td> |
---|
696 | <td valign="top" width="16%">Standard library</td> |
---|
697 | <td valign="top" width="33%">The compiler does not provide a standard compliant |
---|
698 | implementation of std::iterator_traits. Note that the compiler may still have a |
---|
699 | non-standard implementation.</td> |
---|
700 | </tr> |
---|
701 | <tr> |
---|
702 | <td valign="top" width="51%">BOOST_NO_STD_LOCALE</td> |
---|
703 | <td valign="top" width="16%">Standard library</td> |
---|
704 | <td valign="top" width="33%">The standard library lacks std::locale.</td> |
---|
705 | </tr> |
---|
706 | <tr> |
---|
707 | <td valign="top" width="51%">BOOST_NO_STD_MESSAGES</td> |
---|
708 | <td valign="top" width="16%">Standard library</td> |
---|
709 | <td valign="top" width="33%">The standard library lacks a conforming std::messages |
---|
710 | facet.</td> |
---|
711 | </tr> |
---|
712 | <tr> |
---|
713 | <td valign="top" width="51%">BOOST_NO_STD_MIN_MAX</td> |
---|
714 | <td valign="top" width="16%">Standard library</td> |
---|
715 | <td valign="top" width="33%">The C++ standard library does not provide the min() |
---|
716 | and max() template functions that should be in <algorithm>.</td> |
---|
717 | </tr> |
---|
718 | <tr> |
---|
719 | <td valign="top">BOOST_NO_STD_OUTPUT_ITERATOR_ASSIGN</td> |
---|
720 | <td valign="top">Standard library</td> |
---|
721 | <td valign="top">Defined if the standard library's output iterators are not |
---|
722 | assignable.</td> |
---|
723 | </tr> |
---|
724 | <tr> |
---|
725 | <td valign="top" width="51%">BOOST_NO_STD_USE_FACET</td> |
---|
726 | <td valign="top" width="16%">Standard library</td> |
---|
727 | <td valign="top" width="33%">The standard library lacks a conforming |
---|
728 | std::use_facet.</td> |
---|
729 | </tr> |
---|
730 | <tr> |
---|
731 | <td>BOOST_NO_STD_WSTREAMBUF</td> |
---|
732 | <td>Standard library</td> |
---|
733 | <td>The standard library's implementation of std::basic_streambuf<wchar_t> |
---|
734 | is either missing, incomplete, or buggy.</td> |
---|
735 | </tr> |
---|
736 | <tr> |
---|
737 | <td valign="top" width="51%">BOOST_NO_STD_WSTRING</td> |
---|
738 | <td valign="top" width="16%">Standard library</td> |
---|
739 | <td valign="top" width="33%">The standard library lacks std::wstring.</td> |
---|
740 | </tr> |
---|
741 | <tr> |
---|
742 | <td valign="top" width="51%">BOOST_NO_STDC_NAMESPACE</td> |
---|
743 | <td valign="top" width="16%">Compiler/Platform</td> |
---|
744 | <td valign="top" width="33%">The contents of C++ standard headers for C library |
---|
745 | functions (the <c...> headers) have not been placed in namespace std. |
---|
746 | This test is difficult - some libraries "fake" the std C functions by adding |
---|
747 | using declarations to import them into namespace std, unfortunately they don't |
---|
748 | necessarily catch all of them...</td> |
---|
749 | </tr> |
---|
750 | <tr> |
---|
751 | <td valign="top" width="51%">BOOST_NO_STRINGSTREAM</td> |
---|
752 | <td valign="top" width="16%">Standard library</td> |
---|
753 | <td valign="top" width="33%">The C++ implementation does not provide the |
---|
754 | <sstream> header.</td> |
---|
755 | </tr> |
---|
756 | <tr> |
---|
757 | <td valign="top" width="51%">BOOST_NO_SWPRINTF</td> |
---|
758 | <td valign="top" width="16%">Platform</td> |
---|
759 | <td valign="top" width="33%">The platform does not have a conforming version of |
---|
760 | swprintf.</td> |
---|
761 | </tr> |
---|
762 | <tr> |
---|
763 | <td valign="top" width="51%">BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION</td> |
---|
764 | <td valign="top" width="16%">Compiler</td> |
---|
765 | <td valign="top" width="33%">Class template partial specialization (14.5.4 |
---|
766 | [temp.class.spec]) not supported.</td> |
---|
767 | </tr> |
---|
768 | <tr> |
---|
769 | <td valign="top" width="51%">BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS</td> |
---|
770 | <td valign="top" width="16%">Standard library</td> |
---|
771 | <td valign="top" width="33%">The standard library does not provide templated |
---|
772 | iterator constructors for its containers.</td> |
---|
773 | </tr> |
---|
774 | <tr> |
---|
775 | <td>BOOST_NO_TEMPLATE_TEMPLATES</td> |
---|
776 | <td>Compiler</td> |
---|
777 | <td>The compiler does not support template template parameters.</td> |
---|
778 | </tr> |
---|
779 | <tr> |
---|
780 | <td>BOOST_NO_UNREACHABLE_RETURN_DETECTION</td> |
---|
781 | <td>Compiler</td> |
---|
782 | <td>If a return is unreachable, then no return statement should be required, |
---|
783 | however some compilers insist on it, while other issue a bunch of warnings if |
---|
784 | it is in fact present.</td> |
---|
785 | </tr> |
---|
786 | <TR> |
---|
787 | <TD vAlign="top" width="51%">BOOST_NO_USING_DECLARATION_OVERLOADS_FROM_TYPENAME_BASE</TD> |
---|
788 | <TD vAlign="top" width="16%">Compiler</TD> |
---|
789 | <TD vAlign="top" width="33%">The compiler will not accept a using |
---|
790 | declaration that brings a function from a typename used as a base |
---|
791 | class into a derived class if functions of the same name are present |
---|
792 | in the derived class.</TD> |
---|
793 | </TR> |
---|
794 | <tr> |
---|
795 | <td valign="top" width="51%">BOOST_NO_USING_TEMPLATE</td> |
---|
796 | <td valign="top" width="16%">Compiler</td> |
---|
797 | <td valign="top" width="33%">The compiler will not accept a using declaration that |
---|
798 | imports a template class or function from another namespace. Originally a |
---|
799 | Borland specific problem with imports to/from the global namespace, extended to |
---|
800 | MSVC6 which has a specific issue with importing template classes (but not |
---|
801 | functions).</td> |
---|
802 | </tr> |
---|
803 | <tr> |
---|
804 | <td valign="top" width="51%">BOOST_NO_VOID_RETURNS</td> |
---|
805 | <td valign="top" width="16%">Compiler</td> |
---|
806 | <td valign="top" width="33%">The compiler does not allow a void function to return |
---|
807 | the result of calling another void function. |
---|
808 | <pre>void f() {} |
---|
809 | void g() { return f(); }</pre> |
---|
810 | </td> |
---|
811 | </tr> |
---|
812 | </table> |
---|
813 | <h4><a name="features"></a>Macros that describe optional features:</h4> |
---|
814 | <p>The following macros describe features that are not required by the C++ |
---|
815 | standard. The macro is only defined if the feature is present.</p> |
---|
816 | <table border="1" cellpadding="7" cellspacing="1" width="100%"> |
---|
817 | <tr> |
---|
818 | <td valign="top" width="48%"><p align="center"><b>Macro</b></p> |
---|
819 | </td> |
---|
820 | <td valign="top" width="15%"><p align="center"><b>Section</b></p> |
---|
821 | </td> |
---|
822 | <td valign="top" width="37%"><p align="center"><b>Description</b></p> |
---|
823 | </td> |
---|
824 | </tr> |
---|
825 | <tr> |
---|
826 | <td valign="top" width="48%">BOOST_HAS_BETHREADS</td> |
---|
827 | <td valign="top" width="15%">Platform</td> |
---|
828 | <td valign="top" width="37%">The platform supports BeOS style threads.</td> |
---|
829 | </tr> |
---|
830 | <tr> |
---|
831 | <td>BOOST_HAS_CLOCK_GETTIME</td> |
---|
832 | <td>Platform</td> |
---|
833 | <td>The platform has the POSIX API clock_gettime.</td> |
---|
834 | </tr> |
---|
835 | <TR> |
---|
836 | <TD>BOOST_HAS_DECLSPEC |
---|
837 | </TD> |
---|
838 | <TD>Compiler</TD> |
---|
839 | <TD>The compiler uses __declspec(dllexport) and __declspec(dllimport) to |
---|
840 | export/import symbols from dll's.</TD> |
---|
841 | </TR> |
---|
842 | <tr> |
---|
843 | <td>BOOST_HAS_DIRENT_H</td> |
---|
844 | <td>Platform</td> |
---|
845 | <td>The platform has the POSIX header <dirent.h>.</td> |
---|
846 | </tr> |
---|
847 | <tr> |
---|
848 | <td>BOOST_HAS_FTIME</td> |
---|
849 | <td>Platform</td> |
---|
850 | <td>The platform has the Win32 API GetSystemTimeAsFileTime.</td> |
---|
851 | </tr> |
---|
852 | <tr> |
---|
853 | <td>BOOST_HAS_GETTIMEOFDAY</td> |
---|
854 | <td>Platform</td> |
---|
855 | <td>The platform has the POSIX API gettimeofday.</td> |
---|
856 | </tr> |
---|
857 | <tr> |
---|
858 | <td valign="top" width="48%">BOOST_HAS_HASH</td> |
---|
859 | <td valign="top" width="15%">Standard library</td> |
---|
860 | <td valign="top" width="37%">The C++ implementation provides the (SGI) hash_set or |
---|
861 | hash_map classes.</td> |
---|
862 | </tr> |
---|
863 | <tr> |
---|
864 | <td>BOOST_HAS_LONG_LONG</td> |
---|
865 | <td>Compiler</td> |
---|
866 | <td>The compiler supports the long long data type.</td> |
---|
867 | </tr> |
---|
868 | <tr> |
---|
869 | <td valign="top" width="48%">BOOST_HAS_MACRO_USE_FACET</td> |
---|
870 | <td valign="top" width="15%">Standard library</td> |
---|
871 | <td valign="top" width="37%">The standard library lacks a conforming |
---|
872 | std::use_facet, but has a macro _USE(loc, Type) that does the job. This is |
---|
873 | primarily for the Dinkumware std lib.</td> |
---|
874 | </tr> |
---|
875 | <tr> |
---|
876 | <td>BOOST_HAS_MS_INT64</td> |
---|
877 | <td>Compiler</td> |
---|
878 | <td>The compiler supports the __int64 data type.</td> |
---|
879 | </tr> |
---|
880 | <tr> |
---|
881 | <td>BOOST_HAS_NANOSLEEP</td> |
---|
882 | <td>Platform</td> |
---|
883 | <td>The platform has the POSIX API nanosleep.</td> |
---|
884 | </tr> |
---|
885 | <tr> |
---|
886 | <td valign="top" width="48%">BOOST_HAS_NL_TYPES_H</td> |
---|
887 | <td valign="top" width="15%">Platform</td> |
---|
888 | <td valign="top" width="37%">The platform has an <nl_types.h>.</td> |
---|
889 | </tr> |
---|
890 | <tr> |
---|
891 | <td>BOOST_HAS_NRVO</td> |
---|
892 | <td>Compiler</td> |
---|
893 | <td>Indicated that the compiler supports the named return value optimization |
---|
894 | (NRVO). Used to select the most efficient implementation for some function. See <a href="../../boost/operators.hpp"> |
---|
895 | boost/operators.hpp</a> for example.</td> |
---|
896 | </tr> |
---|
897 | <tr> |
---|
898 | <td valign="top">BOOST_HAS_PARTIAL_STD_ALLOCATOR</td> |
---|
899 | <td>Standard Library</td> |
---|
900 | <td>The standard library has a partially conforming std::allocator class, but |
---|
901 | without any of the member templates.</td> |
---|
902 | </tr> |
---|
903 | <tr> |
---|
904 | <td>BOOST_HAS_PTHREAD_DELAY_NP</td> |
---|
905 | <td>Platform</td> |
---|
906 | <td>The platform has the POSIX API pthread_delay_np.</td> |
---|
907 | </tr> |
---|
908 | <tr> |
---|
909 | <td>BOOST_HAS_PTHREAD_MUTEXATTR_SETTYPE</td> |
---|
910 | <td>Platform</td> |
---|
911 | <td>The platform has the POSIX API pthread_mutexattr_settype.</td> |
---|
912 | </tr> |
---|
913 | <tr> |
---|
914 | <td>BOOST_HAS_PTHREAD_YIELD</td> |
---|
915 | <td>Platform</td> |
---|
916 | <td>The platform has the POSIX API pthread_yield.</td> |
---|
917 | </tr> |
---|
918 | <tr> |
---|
919 | <td valign="top" width="48%">BOOST_HAS_PTHREADS</td> |
---|
920 | <td valign="top" width="15%">Platform</td> |
---|
921 | <td valign="top" width="37%">The platform support POSIX style threads.</td> |
---|
922 | </tr> |
---|
923 | <tr> |
---|
924 | <td>BOOST_HAS_SCHED_YIELD</td> |
---|
925 | <td>Platform</td> |
---|
926 | <td>The platform has the POSIX API sched_yield.</td> |
---|
927 | </tr> |
---|
928 | <tr> |
---|
929 | <td>BOOST_HAS_SGI_TYPE_TRAITS</td> |
---|
930 | <td>Compiler/standard library</td> |
---|
931 | <td>The compiler has native support for SGI style type traits.</td> |
---|
932 | </tr> |
---|
933 | <tr> |
---|
934 | <td>BOOST_HAS_STDINT_H</td> |
---|
935 | <td>Platform</td> |
---|
936 | <td>The platform has a <stdint.h></td> |
---|
937 | </tr> |
---|
938 | <tr> |
---|
939 | <td valign="top" width="48%">BOOST_HAS_SLIST</td> |
---|
940 | <td valign="top" width="15%">Standard library</td> |
---|
941 | <td valign="top" width="37%">The C++ implementation provides the (SGI) slist |
---|
942 | class.</td> |
---|
943 | </tr> |
---|
944 | <tr> |
---|
945 | <td valign="top" width="48%">BOOST_HAS_STLP_USE_FACET</td> |
---|
946 | <td valign="top" width="15%">Standard library</td> |
---|
947 | <td valign="top" width="37%">The standard library lacks a conforming |
---|
948 | std::use_facet, but has a workaround class-version that does the job. This is |
---|
949 | primarily for the STLport std lib.</td> |
---|
950 | </tr> |
---|
951 | <tr> |
---|
952 | <td valign="top" width="48%">BOOST_HAS_THREADS</td> |
---|
953 | <td valign="top" width="15%">Platform/compiler</td> |
---|
954 | <td valign="top" width="37%">Defined if the compiler, in its current translation |
---|
955 | mode, supports multiple threads of execution.</td> |
---|
956 | </tr> |
---|
957 | <tr> |
---|
958 | <td valign="top" width="48%">BOOST_HAS_TWO_ARG_USE_FACET</td> |
---|
959 | <td valign="top" width="15%">Standard library</td> |
---|
960 | <td valign="top" width="37%">The standard library lacks a conforming |
---|
961 | std::use_facet, but has a two argument version that does the job. This is |
---|
962 | primarily for the Rogue Wave std lib.</td> |
---|
963 | </tr> |
---|
964 | <tr> |
---|
965 | <td valign="top" width="48%">BOOST_HAS_UNISTD_H</td> |
---|
966 | <td valign="top" width="15%">Platform</td> |
---|
967 | <td valign="top" width="37%">The Platform provides <unistd.h>.</td> |
---|
968 | </tr> |
---|
969 | <tr> |
---|
970 | <td valign="top" width="48%">BOOST_HAS_WINTHREADS</td> |
---|
971 | <td valign="top" width="15%">Platform</td> |
---|
972 | <td valign="top" width="37%">The platform supports MS Windows style threads.</td> |
---|
973 | </tr> |
---|
974 | <tr> |
---|
975 | <td valign="top" width="48%">BOOST_MSVC_STD_ITERATOR</td> |
---|
976 | <td valign="top" width="15%">Standard library</td> |
---|
977 | <td valign="top" width="37%">Microsoft's broken version of std::iterator is being |
---|
978 | used. This implies that std::iterator takes no more than two template |
---|
979 | parameters.</td> |
---|
980 | </tr> |
---|
981 | <tr> |
---|
982 | <td valign="top" width="48%">BOOST_MSVC6_MEMBER_TEMPLATES</td> |
---|
983 | <td valign="top" width="15%">Compiler</td> |
---|
984 | <td valign="top" width="37%">Microsoft Visual C++ 6.0 has enough member template |
---|
985 | idiosyncrasies (being polite) that BOOST_NO_MEMBER_TEMPLATES is defined for |
---|
986 | this compiler. BOOST_MSVC6_MEMBER_TEMPLATES is defined to allow compiler |
---|
987 | specific workarounds. This macro gets defined automatically if |
---|
988 | BOOST_NO_MEMBER_TEMPLATES is not defined - in other words this is treated as a |
---|
989 | strict subset of the features required by the standard.</td> |
---|
990 | </tr> |
---|
991 | <tr> |
---|
992 | <td valign="top" width="48%">BOOST_HAS_STDINT_H</td> |
---|
993 | <td valign="top" width="15%">Platform</td> |
---|
994 | <td valign="top" width="37%">There are no 1998 C++ Standard headers |
---|
995 | <stdint.h> or <cstdint>, although the 1999 C Standard does include |
---|
996 | <stdint.h>. If <stdint.h> is present, <boost/stdint.h> can |
---|
997 | make good use of it, so a flag is supplied (signalling presence; thus the |
---|
998 | default is not present, conforming to the current C++ standard).</td> |
---|
999 | </tr> |
---|
1000 | </table> |
---|
1001 | <h4><a name="helpers"></a>Boost Helper Macros</h4> |
---|
1002 | <p>The following macros are either simple helpers, or macros that provide |
---|
1003 | workarounds for compiler/standard library defects.</p> |
---|
1004 | <table border="1" cellpadding="7" cellspacing="1" width="100%"> |
---|
1005 | <tr> |
---|
1006 | <td valign="top" width="50%"><p align="center"><b>Macro</b></p> |
---|
1007 | </td> |
---|
1008 | <td valign="top" width="50%"><p align="center"><b>Description</b></p> |
---|
1009 | </td> |
---|
1010 | </tr> |
---|
1011 | <tr> |
---|
1012 | <td valign="top" width="50%">BOOST_DEDUCED_TYPENAME</td> |
---|
1013 | <td valign="top" width="50%">Some compilers don't support the use of <code>typename</code> |
---|
1014 | for dependent types in deduced contexts. This macro expands to nothing on those |
---|
1015 | compilers, and <code>typename</code> elsewhere. For example, replace:<pre>template <class T> void f(T, typename T::type);</pre> |
---|
1016 | <p>with:</p> |
---|
1017 | <pre>template <class T> void f(T, BOOST_DEDUCED_TYPENAME T::type);</pre> |
---|
1018 | </td> |
---|
1019 | </tr> |
---|
1020 | <tr> |
---|
1021 | <td>BOOST_STD_EXTENSION_NAMESPACE</td> |
---|
1022 | <td>The namespace used for std library extensions (hashtable classes etc).</td> |
---|
1023 | </tr> |
---|
1024 | <tr> |
---|
1025 | <td valign="top" width="50%">BOOST_STATIC_CONSTANT(Type, assignment)</td> |
---|
1026 | <td valign="top" width="50%">On compilers which don't allow in-class |
---|
1027 | initialization of static integral constant members, we must use enums as a |
---|
1028 | workaround if we want the constants to be available at compile-time. This macro |
---|
1029 | gives us a convenient way to declare such constants. For example instead of:<pre>struct foo{ |
---|
1030 | static const int value = 2; |
---|
1031 | };</pre> |
---|
1032 | <p>use:</p> |
---|
1033 | <pre>struct foo{ |
---|
1034 | BOOST_STATIC_CONSTANT(int, value = 2); |
---|
1035 | };</pre> |
---|
1036 | </td> |
---|
1037 | </tr> |
---|
1038 | <tr> |
---|
1039 | <td>BOOST_UNREACHABLE_RETURN(result)</td> |
---|
1040 | <td>Normally evaluates to nothing, but evaluates to <font face="Courier New">return |
---|
1041 | x;</font> if the compiler requires a return, even when it can never be |
---|
1042 | reached.</td> |
---|
1043 | </tr> |
---|
1044 | <tr> |
---|
1045 | <td>BOOST_EXPLICIT_TEMPLATE_TYPE(t)<br> |
---|
1046 | BOOST_EXPLICIT_TEMPLATE_NON_TYPE(t, v)<br> |
---|
1047 | BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(t)<br> |
---|
1048 | BOOST_APPEND_EXPLICIT_TEMPLATE_NON_TYPE(t, v)<br> |
---|
1049 | </td> |
---|
1050 | <td>Some compilers silently "fold" different function template instantiations if |
---|
1051 | some of the template parameters don't appear in the function parameter list. |
---|
1052 | For instance: |
---|
1053 | <pre> #include <iostream> |
---|
1054 | #include <ostream> |
---|
1055 | #include <typeinfo> |
---|
1056 | |
---|
1057 | template <int n> |
---|
1058 | void f() { std::cout << n << ' '; } |
---|
1059 | |
---|
1060 | template <typename T> |
---|
1061 | void g() { std::cout << typeid(T).name() << ' '; } |
---|
1062 | |
---|
1063 | int main() { |
---|
1064 | f<1>(); |
---|
1065 | f<2>(); |
---|
1066 | |
---|
1067 | g<int>(); |
---|
1068 | g<double>(); |
---|
1069 | } |
---|
1070 | </pre> |
---|
1071 | incorrectly outputs <tt>"2 2 double double "</tt> on VC++ 6. These macros, to |
---|
1072 | be used in the function parameter list, fix the problem without effects on the |
---|
1073 | calling syntax. For instance, in the case above write: |
---|
1074 | <pre> template <int n> |
---|
1075 | void f(BOOST_EXPLICIT_TEMPLATE_NON_TYPE(int, n)) { ... } |
---|
1076 | |
---|
1077 | template <typename T> |
---|
1078 | void g(BOOST_EXPLICIT_TEMPLATE_TYPE(T)) { ... } |
---|
1079 | </pre> |
---|
1080 | Beware that they can declare (for affected compilers) a dummy <i>defaulted</i> parameter, |
---|
1081 | so they |
---|
1082 | <br> |
---|
1083 | <br> |
---|
1084 | a) should be always invoked *at the end* of the parameter list |
---|
1085 | <br> |
---|
1086 | b) can't be used if your function template is multiply declared. |
---|
1087 | <br> |
---|
1088 | <br> |
---|
1089 | Furthermore, in order to add any needed comma separator, an "APPEND_*" version |
---|
1090 | must be used when the macro invocation appears after a normal parameter |
---|
1091 | declaration or after the invocation of another macro of this same group. |
---|
1092 | </td> |
---|
1093 | </tr> |
---|
1094 | <tr> |
---|
1095 | <td valign="top" width="50%">BOOST_USE_FACET(Type, loc)</td> |
---|
1096 | <td valign="top" width="50%">When the standard library does not have a comforming |
---|
1097 | std::use_facet there are various workarounds available, but they differ from |
---|
1098 | library to library. This macro provides a consistent way to access a locale's |
---|
1099 | facets. For example, replace:<pre>std::use_facet<Type>(loc);</pre> |
---|
1100 | <p>with:</p> |
---|
1101 | <pre>BOOST_USE_FACET(Type, loc);</pre> |
---|
1102 | <p>Note do not add a std:: prefix to the front of BOOST_USE_FACET.</p> |
---|
1103 | </td> |
---|
1104 | </tr> |
---|
1105 | <tr> |
---|
1106 | <td valign="top" width="50%">BOOST_HAS_FACET(Type, loc)</td> |
---|
1107 | <td valign="top" width="50%">When the standard library does not have a comforming |
---|
1108 | std::has_facet there are various workarounds available, but they differ from |
---|
1109 | library to library. This macro provides a consistent way to check a locale's |
---|
1110 | facets. For example, replace:<pre>std::has_facet<Type>(loc);</pre> |
---|
1111 | <p>with:</p> |
---|
1112 | <pre>BOOST_HAS_FACET(Type, loc);</pre> |
---|
1113 | <p>Note do not add a std:: prefix to the front of BOOST_HAS_FACET.</p> |
---|
1114 | </td> |
---|
1115 | </tr> |
---|
1116 | <tr> |
---|
1117 | <td valign="top" width="50%">BOOST_NESTED_TEMPLATE</td> |
---|
1118 | <td valign="top" width="50%">Member templates are supported by some compilers even |
---|
1119 | though they can't use the A::template member<U> syntax, as a workaround |
---|
1120 | replace:<pre>typedef typename A::template rebind<U> binder;</pre> |
---|
1121 | <p>with:</p> |
---|
1122 | <pre>typedef typename A::BOOST_NESTED_TEMPLATE rebind<U> binder;</pre> |
---|
1123 | </td> |
---|
1124 | </tr> |
---|
1125 | <tr> |
---|
1126 | <td valign="top" width="50%">BOOST_STRINGIZE(X)</td> |
---|
1127 | <td valign="top" width="50%">Converts the parameter X to a string after macro |
---|
1128 | replacement on X has been performed.</td> |
---|
1129 | </tr> |
---|
1130 | <tr> |
---|
1131 | <td valign="top" width="50%">BOOST_JOIN(X,Y)</td> |
---|
1132 | <td valign="top" width="50%">This piece of macro magic joins the two arguments |
---|
1133 | together, even when one of the arguments is itself a macro (see 16.3.1 in C++ |
---|
1134 | standard). This is normally used to create a mangled name in combination with a |
---|
1135 | predefined macro such a __LINE__.</td> |
---|
1136 | </tr> |
---|
1137 | </table> |
---|
1138 | <h4><a name="info_macros"></a>Boost Informational Macros</h4> |
---|
1139 | <p>The following macros describe boost features; these are, generally speaking |
---|
1140 | the only boost macros that should be tested in user code.</p> |
---|
1141 | <table border="1" cellpadding="7" cellspacing="1" width="100%"> |
---|
1142 | <tr> |
---|
1143 | <td valign="top" width="33%"><p align="center"><b>Macro</b></p> |
---|
1144 | </td> |
---|
1145 | <td valign="top" width="33%"><p align="center"><b>Header</b></p> |
---|
1146 | </td> |
---|
1147 | <td valign="top" width="33%"><p align="center"><b>Description</b></p> |
---|
1148 | </td> |
---|
1149 | </tr> |
---|
1150 | <tr> |
---|
1151 | <td valign="top" width="33%">BOOST_VERSION</td> |
---|
1152 | <td valign="top" width="33%"><boost/version.hpp></td> |
---|
1153 | <td valign="top" width="33%">Describes the boost version number in XXYYZZ format |
---|
1154 | such that: (BOOST_VERSION % 100) is the sub-minor version, ((BOOST_VERSION / |
---|
1155 | 100) % 1000) is the minor version, and (BOOST_VERSION / 100000) is the major |
---|
1156 | version.</td> |
---|
1157 | </tr> |
---|
1158 | <tr> |
---|
1159 | <td valign="top" width="33%">BOOST_NO_INT64_T</td> |
---|
1160 | <td valign="top" width="33%"><boost/cstdint.hpp><p><boost/stdint.h></p> |
---|
1161 | </td> |
---|
1162 | <td valign="top" width="33%">Defined if there are no 64-bit integral types: |
---|
1163 | int64_t, uint64_t etc.</td> |
---|
1164 | </tr> |
---|
1165 | <tr> |
---|
1166 | <td valign="top" width="33%">BOOST_NO_INTEGRAL_INT64_T</td> |
---|
1167 | <td valign="top" width="33%"><boost/cstdint.hpp><p><boost/stdint.h></p> |
---|
1168 | </td> |
---|
1169 | <td valign="top" width="33%">Defined if int64_t as defined by |
---|
1170 | <boost/cstdint.hpp> is not usable in integral constant expressions.</td> |
---|
1171 | </tr> |
---|
1172 | <tr> |
---|
1173 | <td valign="top">BOOST_MSVC</td> |
---|
1174 | <td valign="top"><boost/config.hpp></td> |
---|
1175 | <td valign="top">Defined if the compiler is really Microsoft Visual C++, as |
---|
1176 | opposed to one of the many other compilers that also define _MSC_VER.</td> |
---|
1177 | </tr> |
---|
1178 | <tr> |
---|
1179 | <td valign="top">BOOST_INTEL</td> |
---|
1180 | <td valign="top"><boost/config.hpp></td> |
---|
1181 | <td valign="top">Defined if the compiler is an Intel compiler, takes the same |
---|
1182 | value as the compiler version macro.</td> |
---|
1183 | </tr> |
---|
1184 | <TR> |
---|
1185 | <TD vAlign="top">BOOST_WINDOWS</TD> |
---|
1186 | <TD vAlign="top"><boost/config.hpp></TD> |
---|
1187 | <TD vAlign="top">Defined if the Windows platfrom API is available.</TD> |
---|
1188 | </TR> |
---|
1189 | <tr> |
---|
1190 | <td>BOOST_DINKUMWARE_STDLIB</td> |
---|
1191 | <td><boost/config.hpp></td> |
---|
1192 | <td>Defined if the dinkumware standard library is in use, takes the same value as |
---|
1193 | the Dinkumware library version macro _CPPLIB_VER if defined, otherwise 1.</td> |
---|
1194 | </tr> |
---|
1195 | <tr> |
---|
1196 | <td valign="top" width="33%">BOOST_NO_WREGEX</td> |
---|
1197 | <td valign="top" width="33%"><boost/regex.hpp></td> |
---|
1198 | <td valign="top" width="33%">Defined if the regex library does not support wide |
---|
1199 | character regular expressions.</td> |
---|
1200 | </tr> |
---|
1201 | <tr> |
---|
1202 | <td valign="top" width="33%">BOOST_COMPILER</td> |
---|
1203 | <td valign="top" width="33%"><boost/config.hpp></td> |
---|
1204 | <td valign="top" width="33%">Defined as a string describing the name and version |
---|
1205 | number of the compiler in use. Mainly for debugging the configuration.</td> |
---|
1206 | </tr> |
---|
1207 | <tr> |
---|
1208 | <td valign="top" width="33%">BOOST_STDLIB</td> |
---|
1209 | <td valign="top" width="33%"><boost/config.hpp></td> |
---|
1210 | <td valign="top" width="33%">Defined as a string describing the name and version |
---|
1211 | number of the standard library in use. Mainly for debugging the configuration.</td> |
---|
1212 | </tr> |
---|
1213 | <tr> |
---|
1214 | <td valign="top" width="33%">BOOST_PLATFORM</td> |
---|
1215 | <td valign="top" width="33%"><boost/config.hpp></td> |
---|
1216 | <td valign="top" width="33%">Defined as a string describing the name of the |
---|
1217 | platform. Mainly for debugging the configuration.</td> |
---|
1218 | </tr> |
---|
1219 | </table> |
---|
1220 | <h2><a name="guidelines"></a></h2> |
---|
1221 | <H4><A name="source"></A>Macros for libraries with separate source code</H4> |
---|
1222 | <P>The following macros and helper headers are of use to authors whose libraries |
---|
1223 | include separate source code, and are intended to address two issues: fixing |
---|
1224 | the ABI of the compiled library, and selecting which compiled library to link |
---|
1225 | against based upon the compilers settings.</P> |
---|
1226 | <H5>ABI Fixing</H5> |
---|
1227 | <P>When linking against a pre-compiled library it vital that the ABI used by the |
---|
1228 | compiler when building the library <EM>matches</EM> <EM>exactly</EM> the ABI |
---|
1229 | used by the code using the library. In this case ABI means things like |
---|
1230 | the struct packing arrangement used, the name mangling scheme used, or the size |
---|
1231 | of some types (enum types for example). This is separate from things like |
---|
1232 | threading support, or runtime library variations, which have to be dealt with |
---|
1233 | by build variants. To put this in perspective there is one compiler |
---|
1234 | (Borland's) that has so many compiler options that make subtle changes to the |
---|
1235 | ABI, that at least in theory there 3200 combinations, and that's without |
---|
1236 | considering runtime library variations. Fortunately these variations can |
---|
1237 | be managed by #pragma's that tell the compiler what ABI to use for the types |
---|
1238 | declared in your library. In order to avoid sprinkling #pragma's all over the |
---|
1239 | boost headers, there are some prefix and suffix headers that do the job. |
---|
1240 | Typical usage is:</P> |
---|
1241 | <P><b>my_library.cpp</b></P> |
---|
1242 | <blockquote> |
---|
1243 | <PRE>#ifndef MY_INCLUDE_GUARD |
---|
1244 | #define MY_INCLUDE_GUARD |
---|
1245 | |
---|
1246 | // all includes go here: |
---|
1247 | <b>#include <boost/config.hpp></b> |
---|
1248 | #include <whatever> |
---|
1249 | |
---|
1250 | <b>#include <boost/config/abi_prefix.hpp> // must be the last #include</b> |
---|
1251 | |
---|
1252 | namespace boost{ |
---|
1253 | // your code goes here |
---|
1254 | } |
---|
1255 | |
---|
1256 | <b>#include <boost/config/abi_suffix.hpp> // pops abi_prefix.hpp pragmas</b> |
---|
1257 | |
---|
1258 | #endif // include guard |
---|
1259 | </PRE> |
---|
1260 | </blockquote> |
---|
1261 | <P><b>my_library.cpp</b></P> |
---|
1262 | <blockquote> |
---|
1263 | <pre>... |
---|
1264 | <b>// nothing special need be done in the implementation file</b> |
---|
1265 | ...</pre> |
---|
1266 | </blockquote> |
---|
1267 | <P>The user can disable this mechanism by defining BOOST_DISABLE_ABI_HEADERS, or |
---|
1268 | they can define BOOST_ABI_PREFIX and/or BOOST_ABI_SUFFIX to point to their own |
---|
1269 | prefix/suffix headers if they so wish.</P> |
---|
1270 | <H5>Automatic library selection</H5> |
---|
1271 | <P>It is essential that users link to a build of a library which was built against |
---|
1272 | the same runtime library that their application will be built against - if this |
---|
1273 | does not happen then the library will not be binary compatible with their own |
---|
1274 | code - and there is a high likelihood that their application will |
---|
1275 | experience runtime crashes. These kinds of problems can be extremely |
---|
1276 | time consuming and difficult to debug, and often lead to frustrated users and |
---|
1277 | authors alike (simply selecting the right library to link against is not as |
---|
1278 | easy as it seems when their are 6-8 of them to chose from, and some users seem |
---|
1279 | to be blissfully unaware that there even are different runtimes available to |
---|
1280 | them).</P> |
---|
1281 | <P>To solve this issue, some compilers allow source code to contain #pragma's that |
---|
1282 | instruct the linker which library to link against, all the user need do is |
---|
1283 | include the headers they need, place the compiled libraries in their library |
---|
1284 | search path, and the compiler and linker do the rest. Boost.config |
---|
1285 | supports this via the header <boost/config/auto_link.hpp>, before |
---|
1286 | including this header one or more of the following macros need to be defined:</P> |
---|
1287 | <TABLE id="Table1" cellSpacing="1" cellPadding="1" width="100%" border="1"> |
---|
1288 | <TR> |
---|
1289 | <TD>BOOST_LIB_NAME</TD> |
---|
1290 | <TD> |
---|
1291 | Required: An identifier containing the basename of the library, for |
---|
1292 | example 'boost_regex'.</TD> |
---|
1293 | </TR> |
---|
1294 | <TR> |
---|
1295 | <TD>BOOST_DYN_LINK</TD> |
---|
1296 | <TD>Optional: when set link to dll rather than static library.</TD> |
---|
1297 | </TR> |
---|
1298 | <TR> |
---|
1299 | <TD>BOOST_LIB_DIAGNOSTIC</TD> |
---|
1300 | <TD>Optional: when set the header will print out the name of the library selected |
---|
1301 | (useful for debugging).</TD> |
---|
1302 | </TR> |
---|
1303 | </TABLE> |
---|
1304 | <P>If the compiler supports this mechanism, then it will be told to link against |
---|
1305 | the appropriately named library, the actual algorithm used to mangle the name |
---|
1306 | of the library is documented inside <boost/config/auto_link.hpp> and has |
---|
1307 | to match that used to create the libraries via bjam 's install rules.</P> |
---|
1308 | <P>Typical usage is:</P> |
---|
1309 | <P><b>my_library.hpp</b></P> |
---|
1310 | <blockquote> |
---|
1311 | <PRE>... |
---|
1312 | // |
---|
1313 | // Don't include auto-linking code if the user has disabled it by |
---|
1314 | // defining BOOST_ALL_NO_LIB, or BOOST_MY_LIBRARY_NO_LIB, or if this |
---|
1315 | // is one of our own source files (signified by BOOST_MY_LIBRARY_SOURCE): |
---|
1316 | // |
---|
1317 | <b>#if !defined(BOOST_ALL_NO_LIB) && !defined(BOOST_MY_LIBRARY_NO_LIB) && !defined(BOOST_MY_LIBRARY_SOURCE) |
---|
1318 | # define BOOST_LIB_NAME boost_my_library |
---|
1319 | # ifdef BOOST_MY_LIBRARY_DYN_LINK |
---|
1320 | # define BOOST_DYN_LINK |
---|
1321 | # endif |
---|
1322 | # include <boost/config/auto_link.hpp> |
---|
1323 | #endif |
---|
1324 | </b>... |
---|
1325 | </PRE> |
---|
1326 | </blockquote> |
---|
1327 | <p><b>my_library.cpp</b></p> |
---|
1328 | <blockquote> |
---|
1329 | <pre>// define BOOST_MY_LIBRARY_SOURCE so that the header knows that the |
---|
1330 | // library is being built (possibly exporting rather than importing code) |
---|
1331 | // |
---|
1332 | <b>#define BOOST_MY_LIBRARY_SOURCE</b> |
---|
1333 | |
---|
1334 | <b>#include <boost/my_library/my_library.hpp></b> |
---|
1335 | ...</pre> |
---|
1336 | </blockquote> |
---|
1337 | <H2>Guidelines for Boost Authors</H2> |
---|
1338 | <p>The <a href="../../boost/config.hpp">boost/config.hpp</a> header is used to |
---|
1339 | pass configuration information to other boost files, allowing them to cope with |
---|
1340 | platform dependencies such as arithmetic byte ordering, compiler pragmas, or |
---|
1341 | compiler shortcomings. Without such configuration information, many current |
---|
1342 | compilers would not work with the Boost libraries.</p> |
---|
1343 | <p>Centralizing configuration information in this header reduces the number of |
---|
1344 | files that must be modified when porting libraries to new platforms, or when |
---|
1345 | compilers are updated. Ideally, no other files would have to be modified when |
---|
1346 | porting to a new platform.</p> |
---|
1347 | <p>Configuration headers are controversial because some view them as condoning |
---|
1348 | broken compilers and encouraging non-standard subsets. Adding settings for |
---|
1349 | additional platforms and maintaining existing settings can also be a problem. |
---|
1350 | In other words, configuration headers are a necessary evil rather than a |
---|
1351 | desirable feature. The boost config.hpp policy is designed to minimize the |
---|
1352 | problems and maximize the benefits of a configuration header.</p> |
---|
1353 | <p>Note that:</p> |
---|
1354 | <ul> |
---|
1355 | <li> |
---|
1356 | Boost library implementers are not required to #include |
---|
1357 | <boost/config.hpp>, and are not required in any way to support compilers |
---|
1358 | that do not comply with the C++ Standard (ISO/IEC 14882). |
---|
1359 | <li> |
---|
1360 | If a library implementer wishes to support some non-conforming compiler, or to |
---|
1361 | support some platform specific feature, #include <boost/config.hpp> is |
---|
1362 | the preferred way to obtain configuration information not available from the |
---|
1363 | standard headers such as <climits>, etc. |
---|
1364 | <li> |
---|
1365 | If configuration information can be deduced from standard headers such as |
---|
1366 | <climits>, use those standard headers rather than |
---|
1367 | <boost/config.hpp>. |
---|
1368 | <li> |
---|
1369 | Boost files that use macros defined in <boost/config.hpp> should have |
---|
1370 | sensible, standard conforming, default behavior if the macro is not defined. |
---|
1371 | This means that the starting point for porting <boost/config.hpp> to a |
---|
1372 | new platform is simply to define nothing at all specific to that platform. In |
---|
1373 | the rare case where there is no sensible default behavior, an #error message |
---|
1374 | should describe the problem. |
---|
1375 | <li> |
---|
1376 | If a Boost library implementer wants something added to config.hpp, post a |
---|
1377 | request on the Boost mailing list. There is no guarantee such a request will be |
---|
1378 | honored; the intent is to limit the complexity of config.hpp. |
---|
1379 | <li> |
---|
1380 | The intent is to support only compilers which appear on their way to becoming |
---|
1381 | C++ Standard compliant, and only recent releases of those compilers at that. |
---|
1382 | <li> |
---|
1383 | The intent is not to disable mainstream features now well-supported by the |
---|
1384 | majority of compilers, such as namespaces, exceptions, RTTI, or templates. |
---|
1385 | </li> |
---|
1386 | </ul> |
---|
1387 | <h4><a name="defect_guidelines"></a>Adding New Defect Macros</h4> |
---|
1388 | <p>When you need to add a new defect macro - either to fix a problem with an |
---|
1389 | existing library, or when adding a new library - distil the issue down to a |
---|
1390 | simple test case; often, at this point other (possibly better) workarounds may |
---|
1391 | become apparent. Secondly always post the test case code to the boost mailing |
---|
1392 | list and invite comments; remember that C++ is complex and that sometimes what |
---|
1393 | may appear a defect, may in fact turn out to be a problem with the authors |
---|
1394 | understanding of the standard.</p> |
---|
1395 | <p>When you name the macro, follow the BOOST_NO_SOMETHING naming convention, so |
---|
1396 | that it's obvious that this is a macro reporting a defect.</p> |
---|
1397 | <p>Finally, add the test program to the regression tests. You will need to place |
---|
1398 | the test case in a .ipp file with the following comments near the top:</p> |
---|
1399 | <pre>// MACRO: BOOST_NO_FOO |
---|
1400 | // TITLE: foo |
---|
1401 | // DESCRIPTION: If the compiler fails to support foo</pre> |
---|
1402 | <p>These comments are processed by the autoconf script, so make sure the format |
---|
1403 | follows the one given. The file should be named "boost_no_foo.ipp", where foo |
---|
1404 | is the defect description - try and keep the file name under the Mac 30 |
---|
1405 | character filename limit though. You will also need to provide a function |
---|
1406 | prototype "int test()" that is declared in a namespace with the same name as |
---|
1407 | the macro, but in all lower case, and which returns zero on success:</p> |
---|
1408 | <pre>namespace boost_no_foo{ |
---|
1409 | |
---|
1410 | int test() |
---|
1411 | { |
---|
1412 | // test code goes here: |
---|
1413 | // |
---|
1414 | return 0; |
---|
1415 | } |
---|
1416 | |
---|
1417 | }</pre> |
---|
1418 | <p> |
---|
1419 | Once the test code is in place, build and run the program "generate.cpp" that |
---|
1420 | you will find in the boost-root/libs/config/tools/ directory. This generates |
---|
1421 | two .cpp test files from the new test code, and adds the tests to the |
---|
1422 | regression test Jamfile, and the config_test.cpp test program. Finally add a |
---|
1423 | new entry to config_info.cpp so that the new macro gets printed out when that |
---|
1424 | program is run.</p> |
---|
1425 | <h4><a name="feature_guidelines"></a>Adding New Feature Test Macros</h4> |
---|
1426 | <p>When you need to add a macro that describes a feature that the standard does |
---|
1427 | not require, follow the convention for adding a new defect macro (above), but |
---|
1428 | call the macro BOOST_HAS_FOO, and name the test file "boost_has_foo.ipp". Try |
---|
1429 | not to add feature test macros unnecessarily, if there is a platform specific |
---|
1430 | macro that can already be used (for example _WIN32, __BEOS__, or __linux) to |
---|
1431 | identify the feature then use that. Try to keep the macro to a feature group, |
---|
1432 | or header name, rather than one specific API (for example BOOST_HAS_NL_TYPES_H |
---|
1433 | rather than BOOST_HAS_CATOPEN). If the macro describes a POSIX feature group, |
---|
1434 | then add boilerplate code to <a href="../../boost/config/suffix.hpp">boost/config/suffix.hpp</a> |
---|
1435 | to auto-detect the feature where possible (if you are wondering why we can't |
---|
1436 | use POSIX feature test macro directly, remember that many of these features can |
---|
1437 | be added by third party libraries, and are not therefore identified inside |
---|
1438 | <unistd.h>).</p> |
---|
1439 | <h4><a name="modify_guidelines"></a>Modifying the Boost Configuration Headers</h4> |
---|
1440 | <p>The aim of boost's configuration setup is that the configuration headers should |
---|
1441 | be relatively stable - a boost user should not have to recompile their code |
---|
1442 | just because the configuration for some compiler that they're not interested in |
---|
1443 | has changed. Separating the configuration into separate compiler/standard |
---|
1444 | library/platform sections provides for part of this stability, but boost |
---|
1445 | authors require some amount of restraint as well, in particular:</p> |
---|
1446 | <p><<a href="../../boost/config.hpp">boost/config.hpp</a>> should never |
---|
1447 | change, don't alter this file.</p> |
---|
1448 | <p><<a href="../../boost/config/user.hpp">boost/config/user.hpp</a>> is |
---|
1449 | included by default, don't add extra code to this file unless you have to. If |
---|
1450 | you do, please remember to update <a href="tools/configure.in">libs/config/tools/configure.in</a> |
---|
1451 | as well.</p> |
---|
1452 | <p><<a href="../../boost/config/suffix.hpp">boost/config/suffix.hpp</a>> is |
---|
1453 | always included so be careful about modifying this file as it breaks |
---|
1454 | dependencies for everyone. This file should include only "boilerplate" |
---|
1455 | configuration code, and generally should change only when new macros are added.</p> |
---|
1456 | <p><<a href="../../boost/config/select_compiler_config.hpp">boost/config/select_compiler_config.hpp</a>>, |
---|
1457 | <<a href="../../boost/config/select_platform_config.hpp">boost/config/select_platform_config.hpp</a>> |
---|
1458 | and <<a href="../../boost/config/select_stdlib_config.hpp">boost/config/select_stdlib_config.hpp</a>> |
---|
1459 | are included by default and should change only if support for a new |
---|
1460 | compiler/standard library/platform is added.</p> |
---|
1461 | <p>The compiler/platform/standard library selection code is set up so that unknown |
---|
1462 | platforms are ignored and assumed to be fully standards compliant - this gives |
---|
1463 | unknown platforms a "sporting chance" of working "as is" even without running |
---|
1464 | the configure script.</p> |
---|
1465 | <p>When adding or modifying the individual mini-configs, assume that future, as |
---|
1466 | yet unreleased versions of compilers, have all the defects of the current |
---|
1467 | version. Although this is perhaps unnecessarily pessimistic, it cuts down on |
---|
1468 | the maintenance of these files, and experience suggests that pessimism is |
---|
1469 | better placed than optimism here!</p> |
---|
1470 | <h2><a name="rationale"></a>Rationale</h2> |
---|
1471 | <p>The problem with many traditional "textbook" implementations of configuration |
---|
1472 | headers (where all the configuration options are in a single "monolithic" |
---|
1473 | header) is that they violate certain fundamental software engineering |
---|
1474 | principles which would have the effect of making boost more fragile, more |
---|
1475 | difficult to maintain and more difficult to use safely. You can find a |
---|
1476 | description of the principles from the <a href="http://www.objectmentor.com/publications/Principles%20and%20Patterns.PDF"> |
---|
1477 | following article</a>.</p> |
---|
1478 | <h4>The problem</h4> |
---|
1479 | <p>Consider a situation in which you are concurrently developing on multiple |
---|
1480 | platforms. Then consider adding a new platform or changing the platform |
---|
1481 | definitions of an existing platform. What happens? Everything, and this does |
---|
1482 | literally mean everything, recompiles. Isn't it quite absurd that adding a new |
---|
1483 | platform, which has absolutely nothing to do with previously existing |
---|
1484 | platforms, means that all code on all existing platforms needs to be |
---|
1485 | recompiled?</p> |
---|
1486 | <p>Effectively, there is an imposed physical dependency between platforms that |
---|
1487 | have nothing to do with each other. Essentially, the traditional solution |
---|
1488 | employed by configuration headers does not conform to the Open-Closed |
---|
1489 | Principle:</p> |
---|
1490 | <p><b><i>"A module should be open for extension but closed for modification."</i></b></p> |
---|
1491 | <p>Extending a traditional configuration header implies modifying existing code.</p> |
---|
1492 | <p>Furthermore, consider the complexity and fragility of the platform detection |
---|
1493 | code. What if a simple change breaks the detection on some minor platform? What |
---|
1494 | if someone accidentally or on purpose (as a workaround for some other problem) |
---|
1495 | defines some platform dependent macros that are used by the detection code? A |
---|
1496 | traditional configuration header is one of the most volatile headers of the |
---|
1497 | entire library, and more stable elements of Boost would depend on it. This |
---|
1498 | violates the Stable Dependencies Principle:</p> |
---|
1499 | <p><b><i>"Depend in the direction of stability."</i></b></p> |
---|
1500 | <p>After even a minor change to a traditional configuration header on one minor |
---|
1501 | platform, almost everything on every platform should be tested if we follow |
---|
1502 | sound software engineering practice.</p> |
---|
1503 | <p>Another important issue is that it is not always possible to submit changes to |
---|
1504 | <boost/config.hpp>. Some boost users are currently working on platforms |
---|
1505 | using tools and libraries that are under strict Non-Disclosure Agreements. In |
---|
1506 | this situation it is impossible to submit changes to a traditional monolithic |
---|
1507 | configuration header, instead some method by which the user can insert their |
---|
1508 | own configuration code must be provided.</p> |
---|
1509 | <h4>The solution</h4> |
---|
1510 | <p>The approach taken by boost's configuration headers is to separate |
---|
1511 | configuration into three orthogonal parts: the compiler, the standard library |
---|
1512 | and the platform. Each compiler/standard library/platform gets its own |
---|
1513 | mini-configuration header, so that changes to one compiler's configuration (for |
---|
1514 | example) does not affect other compilers. In addition there are measures that |
---|
1515 | can be taken both to omit the compiler/standard library/platform detection code |
---|
1516 | (so that adding support to a new platform does not break dependencies), or to |
---|
1517 | freeze the configuration completely; providing almost complete protection |
---|
1518 | against dependency changes.</p> |
---|
1519 | <h2><a name="Acknowledgements"></a>Acknowledgements</h2> |
---|
1520 | <p>Beman Dawes provided the original config.hpp and part of this document. Vesa |
---|
1521 | Karvonen provided a description of the principles (see <a href="#rationale">rationale</a>) |
---|
1522 | and put together an early version of the current configuration setup. John |
---|
1523 | Maddock put together the configuration current code, the test programs, the |
---|
1524 | configuration script and the reference section of this document. Numerous boost |
---|
1525 | members, past and present, have contributed fixes to boost's configuration.</p> |
---|
1526 | <p> </p> |
---|
1527 | <hr> |
---|
1528 | <p>© Beman Dawes 2001</p> |
---|
1529 | <p>© Vesa Karvonen 2001</p> |
---|
1530 | <p>© John Maddock 2001</p> |
---|
1531 | <p> </p> |
---|
1532 | <p> </p> |
---|
1533 | <p> </p> |
---|
1534 | <p> </p> |
---|
1535 | <p> </p> |
---|
1536 | </body> |
---|
1537 | </html> |
---|
1538 | |
---|