1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 2<html> 3<head> 4 5 6 <title>Preface</title> 7 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> 8 9 <link href="theme/style.css" rel="stylesheet" type="text/css"> 10</head> 11 12 13<body background="theme/bkd.gif" text="#000000"> 14 15<table background="theme/bkd2.gif" border="0" cellspacing="2" width="100%"> 16 17 <tbody> 18 <tr> 19 20 <td width="21"> 21 <h1></h1> 22 </td> 23 24 <td width="885"> <font face="Verdana, Arial, Helvetica, sans-serif"><b><font size="6">Preface</font></b></font></td> 25 26 <td width="96"><a href="http://www.boost.org"><img src="theme/wave.gif" align="right" border="0" height="68" width="93"></a></td> 27 28 </tr> 29 30 </tbody> 31</table> 32 33<br> 34 35<table border="0"> 36 37 <tbody> 38 <tr> 39 40 <td width="10"></td> 41 42 <td width="30"><a href="../index.html"><img src="theme/u_arr.gif" border="0"></a></td> 43 44 <td width="30"><img src="theme/l_arr_disabled.gif" border="0" height="19" width="20"></td> 45 46 <td width="30"><a href="introduction.html"><img src="theme/r_arr.gif" border="0"></a></td> 47 48 </tr> 49 50 </tbody> 51</table> 52 53<p>During the last time many new features have been developed as additions to the <tt>Spirit</tt> 54 <a href="references.html#spirit">[4]</a> parser construction framework and we 55 felt more and more, that it would be very helpful, to have a 'real world' example, 56 which could be used as a sandbox for testing the usability of certain features. 57 Additionally a recent discussion on the Boost mailing list showed the widespread 58 interest of developers to have a modern, open source C++ preprocessor library 59 to play with. So we had the idea to implement a C++ preprocessor to fit 60 this needs - <tt>Wave</tt> was born.</p> 61 62<p align="justify">The <tt>Wave</tt> C++ preprocessor library uses the <a href="http://www.boost.org/"> 63 </a> <tt>Spirit<a href="references.html#spirit">[4]</a></tt> parser construction 64 library to implement a C++ lexer with ISO/ANSI Standards conformant preprocessing 65 capabilities. It exposes an iterator interface, which returns the current preprocessed 66 token from the input stream. This preprocessed token is generated on the fly 67 while iterating over the preprocessor iterator sequence (in the terminology 68 of the STL these iterators are forward iterators). </p> 69 70<p align="justify"> The C++ preprocessor is a macro processor that under normal 71 circumstances is used automatically by your C++ compiler to transform your program 72 before actual compilation. It is called a macro processor because it allows 73 to define macros, which are brief abbreviations for longer constructs. The 74 C++ preprocessor provides four separate facilities that you can use as you see 75 fit: </p> 76 77<blockquote> 78 79 <p><b><img src="theme/bullet.gif" id="IMG1" height="13" width="13"> </b>Inclusion 80 of header files<br> 81 82 <b><img src="theme/bullet.gif" id="IMG2" height="13" width="13"> </b>Macro 83 expansion<br> 84 85 <b><img src="theme/bullet.gif" id="IMG3" height="13" width="13"> </b>Conditional 86 compilation<br> 87 88 <b><img src="theme/bullet.gif" id="IMG4" height="13" width="13"> </b>Line 89 control</p> 90 91</blockquote> 92 93<p>These features are greatly underestimated today, even more, the preprocessor 94 has been frowned on for so long that its usage just hasn't been effectively 95 pushed until the Boost preprocessor library <a href="references.html#pp_lib">[7]</a> 96 came into being a few years ago. Only today we begin to understand, that preprocessor 97 generative metaprogramming combined with template metaprogramming in C++ is 98 by far one of the most powerful compile-time reflection/metaprogramming facilities 99 that any language has ever supported.</p> 100 101<p>The C++ Standard <a href="http://webstore.ansi.org/ansidocstore/product.asp?sku=INCITS%2FISO%2FIEC%2B14882%2D1998">[2] </a> 102was adopted back in 1998, but there is still no (known to me) 103commercial C++ compiler, which has a bugfree implementation of the 104rather simple preprocessor requirements mandated therein. This may be a 105result of the mentioned underestimation or even banning of the 106preprocessor from good programming style during the last few years or 107may stem from the somewhat awkward standardese dialect of English used 108to describe it. Two open source projects are exceptions of this: gcc 109and Clang (a subproject of LLVM), both providing preprocessors with 110very good standards conformance. </p> 111 112<p align="justify">So the main goals for the <tt>Wave</tt> project are:</p> 113 114<blockquote> 115 116 <p><b><img src="theme/bullet.gif" id="IMG5" height="13" width="13"> </b>full 117 conformance with the C++ standard (ISO/IEC 14882:1998) <a href="references.html#iso_cpp">[1]</a> 118 and with the C99 standard (INCITS/ISO/IEC 9899:1999) <a href="references.html#iso_c">[2]</a><br> 119 120 <b><img src="theme/bullet.gif" height="13" width="13"> </b>usage of <tt>Spirit<a href="references.html#spirit">[4]</a></tt> 121 for the parsing parts of the game (certainly :-)<br> 122 123 <b><img src="theme/bullet.gif" height="13" width="13"> </b>maximal usage 124 of STL and/or <tt>Boost</tt> libraries (for compactness and maintainability)<br> 125 126 <b><img src="theme/bullet.gif" height="13" width="13"> </b>straightforward 127 extendability for the implementation of additional features<br> 128 129 <b><img src="theme/bullet.gif" height="13" width="13"> </b>building a 130 flexible library for different C++ lexing and preprocessing needs</p> 131 132</blockquote> 133 134<p>At the first steps it is not planned to make a very high performance 135or very small C++ preprocessor. If you are looking for these objectives 136you probably have to look at other places. Although our C++ 137preprocessor iterator works as expected and is usable as a reference 138implementation, for instance for testing of other preprocessor oriented 139libraries as the Boost Preprocessor library <a href="references.html#pp_lib">[7]</a> et.al. Nevertheless recent work has lead to surprising performance enhancements (if compared 140 with earlier versions). Wave is still somewhat slower as for instance EDG 141 based preprocessors (Intel, Comeau) on simple input files, however, as 142 complexity increases, time dilates exponentially on EDG. Preprocessing time 143 dilates linearly under Wave, which causes it to easily outperform EDG based 144preprocessors when complexity increases.</p> 145 146<p>As tests showed, the <tt>Wave</tt> library is very conformant to the C++ Standard, 147 such that it compiles several strict conformant macro definitions, which are 148not even compilable with EDG based preprocessors (i.e. Comeau or Intel). </p> 149 150<table border="0"> 151 152 <tbody> 153 <tr> 154 155 <td width="10"></td> 156 157 <td width="30"><a href="../index.html"><img src="theme/u_arr.gif" border="0"></a></td> 158 159 <td width="30"><img src="theme/l_arr_disabled.gif" border="0" height="19" width="20"></td> 160 161 <td width="30"><a href="introduction.html"><img src="theme/r_arr.gif" border="0"></a></td> 162 163 </tr> 164 165 </tbody> 166</table> 167 168<hr size="1"> 169<p class="copyright">Copyright © 2003-2011 Hartmut Kaiser<br> 170 171 <br> 172 173<font size="2">Distributed under the Boost Software License, Version 1741.0. (See accompanying file LICENSE_1_0.txt or copy at 175http://www.boost.org/LICENSE_1_0.txt) </font> </p> 176 177<span class="updated"></span> 178<p class="copyright"><span class="updated">Last updated: 179 <!-- #BeginDate format:fcAm1m -->Sunday, January 9, 2011 16:17<!-- #EndDate --> 180</span></p> 181 182</body> 183</html> 184