preprocessor/doc/ref/line.html
Rene Rivera eb1edeed0b Fix freshly broken links.
[SVN r34734]
2006-07-26 01:19:35 +00:00

113 lines
4.3 KiB
HTML
Raw Permalink Blame History

<html>
<head>
<title>BOOST_PP_LINE</title>
<link rel="stylesheet" type="text/css" href="../styles.css">
</head>
<body>
<div style="margin-left: 0px;">
The <b>BOOST_PP_LINE</b> macro places notes encoded as line directives in the preprocessing output.
</div>
<h4>Usage</h4>
<div class="code">
#line <b>BOOST_PP_LINE</b>(<i>line</i>, <i>file</i>)
</div>
<h4>Arguments</h4>
<dl>
<dt>line</dt>
<dd>
The new line number of the trailing line.&nbsp;
The predefined macro <i>__LINE__</i> is commonly used.
</dd>
<dt>file</dt>
<dd>
Typically the name of the current file.&nbsp;
However, any informative text will work.&nbsp;
This text is internally stringized, so quotation marks are unnecessary.
</dd>
</dl>
<h4>Remarks</h4>
<div>
If the macro <b>BOOST_PP_CONFIG_EXTENDED_LINE_INFO</b> is defined as <i>1</i> and a <i>file-iteration</i>
is in progress, this macro will automatically insert debugging information about the state of <i>file-iteration</i>.&nbsp;
This information will show the all of the current iteration values with the inner most iteration last.
</div>
<div>
This information is useful when errors might be spanning multiple iterations of the same source text.&nbsp;
Finding any errors is sometimes less than straightforward.&nbsp;
Use of this macro can provide information to make this much easier.&nbsp;
For example, instead of getting several errors like this:
<div><i>
"file.hpp", line 2: error: expected a ";"<br>
"file.hpp", line 4: error: improperly terminated macro invocation<br>
</i></div>
You might get something like this instead....
<i><div>
"file.hpp [1]", line 2: error: expected a ";"<br>
"file.hpp [5]", line 4: error: improperly terminated macro invocation<br>
</i></div>
It is immediately evident that this error is spanning multiple iterations of the same source text.&nbsp;
If it wasn't, the same errors would occur on each iteration.
</div>
<div>
It must be noted however, that some compilers don't like filenames that aren't actually files.&nbsp;
Those compilers typically issues warnings about the bad filename.&nbsp;
This makes it a good idea to only define <b>BOOST_PP_CONFIG_EXTENDED_LINE_INFO</b> to <i>1</i> <i>only</i> when debugging.
</div>
<h4>See Also</h4>
<ul>
<li><a href="config_extended_line_info.html">BOOST_PP_CONFIG_EXTENDED_LINE_INFO</a></li>
</ul>
<h4>Requirements</h4>
<div>
<b>Header:</b> &nbsp;<a href="../headers/debug/line.html">&lt;boost/preprocessor/debug/line.hpp&gt;</a>
</div>
<h4>Sample Code</h4>
<div><pre>
// sample.cpp
#if !defined(<a href="is_iterating.html">BOOST_PP_IS_ITERATING</a>)
#define <a href="config_extended_line_info.html">BOOST_PP_CONFIG_EXTENDED_LINE_INFO</a> 1
#include &lt;<a href="../headers/arithmetic/dec.html">boost/preprocessor/arithmetic/dec.hpp</a>&gt;
#include &lt;<a href="../headers/cat.html">boost/preprocessor/cat.hpp</a>&gt;
#include &lt;<a href="../headers/debug/line.html">boost/preprocessor/debug/line.hpp</a>&gt;
#include &lt;<a href="../headers/iteration/iterate.html">boost/preprocessor/iteration/iterate.hpp</a>&gt;
namespace sample {
#define <a href="iteration_params_x.html">BOOST_PP_ITERATION_PARAMS_1</a> (3, (1, 5, "sample.cpp"))
#include <a href="iterate.html">BOOST_PP_ITERATE</a>()
} // sample
int main(void) {
return 0;
}
#else
#line <a href="line.html">BOOST_PP_LINE</a>(1, sample.cpp)
int <a href="cat.html">BOOST_PP_CAT</a>(x, <a href="iteration.html">BOOST_PP_ITERATION</a>())); // extra parenthesis
struct <a href="cat.html">BOOST_PP_CAT</a>(s, <a href="dec.html">BOOST_PP_DEC</a>(<a href="iteration.html">BOOST_PP_ITERATION</a>()) {
// missing a parenthesis
// ...
};
#endif
</pre></div>
<hr size="1">
<div style="margin-left: 0px;">
<i><EFBFBD> Copyright <a href="http://www.housemarque.com" target="_top">Housemarque Oy</a> 2002</i>
</br><i><EFBFBD> Copyright Paul Mensonides 2002</i>
</div>
<div style="margin-left: 0px;">
<p><small>Distributed under the Boost Software License, Version 1.0. (See
accompanying file <a href="../../../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> or
copy at <a href=
"http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</a>)</small></p>
</div>
</body>
</html>