compiletime_config.html 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  2. <html>
  3. <head>
  4. <title>Compile Time Configuration</title>
  5. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  6. <link href="theme/style.css" rel="stylesheet" type="text/css">
  7. </head>
  8. <body>
  9. <table width="100%" border="0" cellspacing="2" background="theme/bkd2.gif">
  10. <tr>
  11. <td width="21"> <h1></h1></td>
  12. <td width="885"> <font face="Verdana, Arial, Helvetica, sans-serif"><b><font size="6">Compile
  13. Time Configuration</font></b></font></td>
  14. <td width="96"><a href="http://www.boost.org"><img src="theme/wave.gif" width="93" height="68" align="right" border="0"></a></td>
  15. </tr>
  16. </table>
  17. <br>
  18. <table border="0">
  19. <tr>
  20. <td width="10"></td>
  21. <td width="30"><a href="../index.html"><img src="theme/u_arr.gif" border="0"></a></td>
  22. <td width="30"><a href="macro_expansion_process.html"><img src="theme/l_arr.gif" width="20" height="19" border="0"></a></td>
  23. <td width="30"><a href="samples.html"><img src="theme/r_arr.gif" border="0"></a></td>
  24. </tr>
  25. </table>
  26. <p><b><a name="compiletime_config"></a>Library compile time configuration</b></p>
  27. <P dir="ltr">The C++ preprocessor iterator library may be configured at compile
  28. time by specifying different preprocessor constants to include different additional
  29. features. The possible preprocessor constants are described in the following
  30. table. </P>
  31. <table width="100%" border="0" align="center">
  32. <tr>
  33. <td colspan="2" class="table_title"><b>Summary of possible preprocessor constants
  34. for<br>
  35. library configuration</b></td>
  36. </tr>
  37. <tr>
  38. <td width="46%" class="table_cells"><code>BOOST_WAVE_SUPPORT_WARNING_DIRECTIVE</code></td>
  39. <td width="54%" class="table_cells"> <p>Support the <span class="preprocessor">#warning</span> directive</p></td>
  40. </tr>
  41. <tr>
  42. <td width="46%" class="table_cells"><code>BOOST_WAVE_SUPPORT_MS_EXTENSIONS</code></td>
  43. <td width="54%" class="table_cells"> <p>Support several MS specific language
  44. extensions (i.e. <tt>__int8</tt> et.al.)</p></td>
  45. </tr>
  46. <tr>
  47. <td class="table_cells"><code>BOOST_WAVE_PREPROCESS_ERROR_MESSAGE_BODY</code></td>
  48. <td class="table_cells"><p>Enable the preprocessing of the message bodies
  49. of <span class="preprocessor">#error</span> and <span class="preprocessor">#warning</span>
  50. directives.</p></td>
  51. </tr>
  52. <tr>
  53. <td class="table_cells"><code>BOOST_WAVE_EMIT_PRAGMA_DIRECTIVES</code></td>
  54. <td class="table_cells"><p>If defined, then the <span class="preprocessor">#pragma</span>
  55. directives are returned as a token sequence to the caller, if not defined,
  56. the whole <span class="preprocessor">#pragma</span> directive is skipped. </p></td>
  57. </tr>
  58. <tr>
  59. <td class="table_cells"><code>BOOST_WAVE_PREPROCESS_PRAGMA_BODY</code></td>
  60. <td class="table_cells"><p>Enable the preprocessing of the bodies of all <span class="preprocessor">
  61. #pragma</span> directives.<br>
  62. Note though, that the body of an <tt>operator&nbsp;_Pragma()</tt> is always preprocessed as this is required by the C99 Standard <a href="references.html#iso_c">[2]</a>.
  63. </p></td>
  64. </tr>
  65. <tr>
  66. <td class="table_cells"><code>BOOST_WAVE_ENABLE_COMMANDLINE_MACROS</code></td>
  67. <td class="table_cells"><p>Enable the functionality required to define macros
  68. with the command line syntax (-DMACRO(x)=definition)</p></td>
  69. </tr>
  70. <tr>
  71. <td class="table_cells"><code>BOOST_WAVE_STRINGTYPE</code></td>
  72. <td class="table_cells"><p>The tokens generated by the <tt>Wave</tt> library
  73. contain the token data and the file position, where this token was found
  74. in the input stream. <br>
  75. This constant may be used to redefine the data type, which is used to
  76. hold the token data and the corresponding file name. If this isn't defined
  77. it defaults to std::string. (The here defined data type should be compatible
  78. to the std::string type)</p></td>
  79. </tr>
  80. <tr>
  81. <td class="table_cells"><code>BOOST_WAVE_SUPPORT_VARIADICS_PLACEMARKERS</code></td>
  82. <td class="table_cells"><p>If defined, then the preprocessor library supports
  83. variadics and placemarkers. Note, to support C99 mode, this constant must
  84. be defined too.</p></td>
  85. </tr>
  86. <tr>
  87. <td class="table_cells"><code>BOOST_WAVE_SUPPORT_CPP0X</code></td>
  88. <td class="table_cells"><p>If defined, then the preprocessor library supports
  89. C++0x keywords and C++0x specific features, such as variadics, placemarkers, extended character and string literals. This implies the definitions of the <code>BOOST_WAVE_SUPPORT_VARIADICS_PLACEMARKERS</code> constant.</p></td>
  90. </tr> <tr>
  91. <td class="table_cells"><code>BOOST_WAVE_MAX_INCLUDE_LEVEL_DEPTH</code></td>
  92. <td class="table_cells"><p>If defined, it will determine the initial maximal
  93. possible include file nesting depth supported. It defaults to 1024.</p></td>
  94. </tr>
  95. <tr>
  96. <td class="table_cells"><code>BOOST_WAVE_SUPPORT_PRAGMA_ONCE</code></td>
  97. <td class="table_cells"><p>If defined, then the <code>#pragma once</code> directive is supported by <tt>Wave</tt>. This specifies that the file, in which the pragma resides, will be included
  98. (opened) only once by the compiler in a build. </p></td>
  99. </tr>
  100. <tr>
  101. <td class="table_cells"><code>BOOST_WAVE_SUPPORT_PRAGMA_MESSAGE</code></td>
  102. <td class="table_cells"><p>If defined, then the <code class="preprocessor">#pragma message(&quot;&quot;)</code> directive is supported by <tt>Wave</tt>. This pragma simply generates a remark cotaining the message text. The body of the #pragma message is preprocessed whenever the <code><code>BOOST_</code>WAVE_PREPROCESS_PRAGMA_BODY</code> constant is defined as well . </p></td>
  103. </tr>
  104. <tr>
  105. <td class="table_cells"><code>BOOST_WAVE_SUPPORT_INCLUDE_NEXT</code></td>
  106. <td class="table_cells"><p>If defined, then the <code>#include_next</code> directive is supported by <tt>Wave</tt>. This is syntactically equivalent to the <code class="preprocessor">#include</code> directives, but may be used to inherit a header file (i.e. to include a file, which is named as the current file containing the <code>#include_next</code>).</p></td>
  107. </tr>
  108. <tr>
  109. <td class="table_cells"><code>BOOST_WAVE_USE_STRICT_LEXER</code></td>
  110. <td class="table_cells"><p>If this is defined to something != 0, then the C/C++ lexers recognize the
  111. strict C99/C++ basic source character set. If it is not defined or defined
  112. to zero, the lexers recognize the <span class="string">'$'</span> character as part of identifiers.</p></td>
  113. </tr>
  114. <tr>
  115. <td class="table_cells"><code>BOOST_WAVE_PRAGMA_KEYWORD</code></td>
  116. <td class="table_cells"><p>If this is defined to a string literal it will be used as the pragma keyword recogniyed by the library as specific Wave pragma's. This constant defaults to <span class="literal">&quot;wave&quot;</span>, i.e. the library recognizes all <span class="preprocessor">#pragma wave option [(argument)]</span> directives and dispatches the handling to the interpret_pragma() preprocessing hook function (see: <a href="class_reference_ctxpolicy.html">Preprocessing Hooks</a>). The arguments part of the pragma is optional.<br>
  117. </p> </td>
  118. </tr>
  119. <tr>
  120. <td class="table_cells"><code>BOOST_WAVE_USE_DEPRECIATED_PREPROCESSING_HOOKS</code></td>
  121. <td class="table_cells"><p>If defined to something not equal to zero (<span class="literal">'0'</span>) Wave will be compiled to use the depreciated preprocessing hooks. The interface of the preprocessing hooks has been changed after the Boost V1.34.x releases. This constant allows to compile applications using the older interface. </p></td>
  122. </tr>
  123. <tr>
  124. <td class="table_cells"><code>BOOST_WAVE_SUPPORT_LONGLONG_INTEGER_LITERALS</code></td>
  125. <td class="table_cells"><p>The C++ standard requires the preprocessor to use one of the following
  126. types for integer literals: <code>long</code> or <code>unsigned long</code> depending on a optional
  127. suffix (<span class="literal">'u'</span>, <span class="literal">'l'</span>, <span class="literal">'ul'</span>, or <span class="literal">'lu'</span>). Sometimes it is required to preprocess integer literals larger than that
  128. (i.e. <code>long long</code> or <code>unsigned long long</code>). Defining this pp constant enables the recognition of long long integers
  129. even if these do not have the <span class="literal">'ll'</span> suffix.</p>
  130. <p>This preprocessor constant is effective only, if your target platform supports
  131. long long integers (<code>BOOST_HAS_LONG_LONG</code> is defined). Please note, that this setting doesn't relate to the Wave support option
  132. <code>support_option_long_long</code>, which enables the recognition of <span class="literal">'ll'</span> suffixes
  133. only.
  134. </p>
  135. </td>
  136. </tr>
  137. <tr>
  138. <td class="table_cells">
  139. <code>BOOST_WAVE_SUPPORT_THREADING</code></td>
  140. <td class="table_cells">
  141. <p>This preprocessor constant allows to configer whether the Wave library will be built
  142. with threading support enabled or not. This value (if defined) should be set to
  143. zero ('0') if threading needs to be disabled and to a numerical value not equal
  144. to zero, if threading should be enabled explicitely.
  145. </p>
  146. <p>
  147. If this constant is not defined, the Wave library will be built using the threading
  148. as picked up from the Boost build environment (see <code>BOOST_HAS_THREADS</code> in the Boost
  149. configuration dosumentation).</p>
  150. </td>
  151. </tr>
  152. </table>
  153. <P dir="ltr"><b><a name="using_custom_lexer"></a>Using a different token type or lexer type in conjunction with Wave </b></P>
  154. <P dir="ltr">It is possible to use the <tt>Wave</tt> library while using your own token and/or lexer types. This may be achieved by providing your lexer type as the second template parameter while instantiating the <tt>boost::wave::context&lt;&gt;</tt> object. The token type used by the library is derived from the <tt>token_type</tt> typedef to be provided by the lexer type. If you want to provide your own token type only, you may use the <tt>boost::wave::lex_iterator&lt;&gt;</tt> type contained with the library. This type needs to be parametrized with the token type to use. </P>
  155. <P dir="ltr">The <tt>Wave</tt> library contains several samples illustrating these possibilities. The <tt>cpp_tokens</tt> sample shows the usage of a custom lexer and a custom token types. The lexer type used is functionally fully compatible to the <tt>re2c</tt> <a href="references.html#re2c">[3]</a> based lexer used by default. It is implemented based on the <tt>SLex</tt> <a href="references.html#slex">[5]</a> lexer example written by Dan Nuffer. The token type used therein is functionally equivalent to the default token type except for an additional <tt>operator&lt;&lt;</tt> used for dumping the information carried by the token.</P>
  156. <P dir="ltr"><b><a name="compilation_models"></a>Separation and inclusion compilation
  157. models</b></P>
  158. <P dir="ltr">The <tt>Wave</tt> C++ preprocessor iterator library is build almost
  159. completely as a header only library (except for the re2c based lexer). If you're
  160. trying to include all required files at once you will mention, that the resulting
  161. compilation times are very large (up to an hour - depending on your system configuration).
  162. This straightforward method we'll call the inclusion compilation model. If you
  163. do not pay attention to compilation times, that's the way to go, no special
  164. handling is needed.</P>
  165. <P dir="ltr">If you're interested in decreasing compilation times, the following
  166. method is to be used. This we will call it the separation compilation model.
  167. The trick is to separate the different objects such, that they are compilable
  168. separately. The function, which instantiates the templated object in question
  169. is factored out such, that its definition is visible to only one translation
  170. unit. To simplify this further this creation function is packaged into a small
  171. generator template structure.</P>
  172. <P dir="ltr">There are two levels of separation implemented: the separation of
  173. the compilation of the C++ lexer and the separation of the compilation of the
  174. different Spirit grammars used. To use these separations you will have to define
  175. two preprocessor constants while compiling the whole application and you will
  176. have to explicitely instantiate some helper templates. The following tables
  177. shows these constants in detail.</P>
  178. <table width="90%" border="0" align="center">
  179. <tr>
  180. <td colspan="2" class="table_title"><b>Summary of possible compilation constants
  181. required <br>
  182. to enable the separation compilation model</b></td>
  183. </tr>
  184. <tr class="table_title">
  185. <td width="25%"><b>Separate</b></td>
  186. <td width="75%"><p><code><font face="Verdana, Arial, Helvetica, sans-serif">Preprocessor
  187. constant</font></code></p></td>
  188. </tr>
  189. <tr>
  190. <td width="25%" class="table_cells"><code>C++ lexer</code></td>
  191. <td width="75%" class="table_cells"> <p><code><code>BOOST_</code>WAVE_SEPARATE_LEXER_INSTANTIATION</code></p></td>
  192. </tr>
  193. <tr>
  194. <td width="25%" class="table_cells"><code>Spirit grammars</code></td>
  195. <td width="75%" class="table_cells"> <p><code><code>BOOST_</code>WAVE_SEPARATE_GRAMMAR_INSTANTIATION</code></p></td>
  196. </tr>
  197. </table>
  198. <P dir="ltr">The following table shows the explicit template instantiations required,
  199. if you want to use the separation compilation model. The <tt>TokenT</tt> placeholder
  200. type has to be replaced with your token type to use and the <code><tt>LexIteratorT</tt></code> placeholder type has to be replaced with your lex iterator type you've used while instantiation of the <tt>boost::wave::context&lt;&gt;</tt> object. You will achieve the best
  201. results, if you place these into separate compilation units each. The <tt>IteratorT</tt>
  202. placeholder should be replaced by the iterator type, which was used to instantiate
  203. the <tt>boost::wave::context&lt;&gt;</tt> object.</P>
  204. <table width="90%" border="0" align="center">
  205. <tr>
  206. <td colspan="2" class="table_title"><b>Summary of required explicit template
  207. instantiations <br>
  208. required when using the separation compilation model</b></td>
  209. </tr>
  210. <tr class="table_title">
  211. <td width="25%"><b>Separate</b></td>
  212. <td width="75%"><p><code><font face="Verdana, Arial, Helvetica, sans-serif">Templates
  213. to explicitly instantiate</font></code></p></td>
  214. </tr>
  215. <tr>
  216. <td width="25%" class="table_cells"><code>C++ lexer</code></td>
  217. <td width="75%" class="table_cells"> <code><span class="keyword">template</span>
  218. cpplexer::re2clex::new_lexer_gen&lt;<tt>IteratorT</tt>&gt;;</code></td>
  219. </tr>
  220. <tr>
  221. <td width="25%" class="table_cells"><code>Spirit grammars</code></td>
  222. <td width="75%" class="table_cells"> <p><code><span class="keyword">template</span> wave::grammars::expression_grammar_gen&lt<tt>TokenT</tt>&gt;;<br>
  223. <span class="keyword"> template</span> wave::grammars::intlit_grammar_gen&lt;<tt>TokenT</tt>&gt;;<br>
  224. <span class="keyword"> template</span> wave::grammars::chlit_grammar_gen&lt;<tt>TokenT</tt>&gt;;<br>
  225. <span class="keyword"> template</span> wave::grammars::cpp_grammar_gen&lt;<tt>LexIteratorT</tt>&gt;;<br>
  226. <span class="keyword"> template</span> wave::grammars::predefined_macros_grammar_gen&lt;<tt>LexIteratorT</tt>&gt;;<br>
  227. <span class="keyword"> template</span> wave::grammars::defined_grammar_gen&lt;<tt>LexIteratorT</tt>&gt;;</code></p></td>
  228. </tr>
  229. </table>
  230. <p>To see an example of this you can look at the <tt>Wave</tt> driver program
  231. included as an acompanion sample to the C++ preprocessor iterator library. The
  232. corresponding files are named obviously <span class="string">&quot;instantiate_...something.cpp&quot;</span>,
  233. where the <span class="string">'...somthing'</span> is a hint, which grammars
  234. are explicitely instantiated inside. By using the separation model the compilation
  235. times required to build the <tt>Wave</tt> example are dropped by up to 90%.</p>
  236. <table border="0">
  237. <tr>
  238. <td width="10"></td>
  239. <td width="30"><a href="../index.html"><img src="theme/u_arr.gif" border="0"></a></td>
  240. <td width="30"><a href="macro_expansion_process.html"><img src="theme/l_arr.gif" width="20" height="19" border="0"></a></td>
  241. <td width="30"><a href="samples.html"><img src="theme/r_arr.gif" border="0"></a></td>
  242. </tr>
  243. </table>
  244. <hr size="1">
  245. <p class="copyright">Copyright &copy; 2003-2011 Hartmut Kaiser<br>
  246. <br>
  247. <font size="2">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) </font> </p>
  248. <span class="updated"></span>
  249. <p class="copyright"><span class="updated">Last updated:
  250. <!-- #BeginDate format:fcAm1m -->Sunday, January 9, 2011 16:16<!-- #EndDate -->
  251. </span></p>
  252. </body>
  253. </html>