Files
preprocessor/docs.1/ref/line.html
Paul Mensonides cdc4be5256 initial revision
[SVN r15198]
2002-09-08 09:40:56 +00:00

104 lines
3.5 KiB
HTML

<html>
<head>
<title>BOOST_PP_LINE</title>
<link rel="stylesheet" type="text/css" href="../styles.css">
<script language="javascript" type="text/javascript" src="../scripts.js"></script>
</head>
<body onload="init('sample');">
<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.hpp.html">&lt;boost/preprocessor/debug/line.hpp&gt;</a>
</div>
<h4><a class="local" onclick="toggle('sample');" onmouseover="change(this);" onmouseout="revert(this);">Sample Code</a></h4>
<div id="sample"><pre>
// sample.cpp
#if !defined(BOOST_PP_IS_ITERATING)
#define BOOST_PP_CONFIG_EXTENDED_LINE_INFO 1
#include &lt;boost/preprocessor/arithmetic/dec.hpp&gt;
#include &lt;boost/preprocessor/cat.hpp&gt;
#include &lt;boost/preprocessor/debug/line.hpp&gt;
#include &lt;boost/preprocessor/iteration/iterate.hpp&gt;
namespace sample {
#define BOOST_PP_ITERATION_PARAMS_1 (3, (1, 5, "sample.cpp"))
#include BOOST_PP_ITERATE()
} // sample
int main(void) {
return 0;
}
#else
#line BOOST_PP_LINE(1, sample.cpp)
int BOOST_PP_CAT(x, BOOST_PP_ITERATION())); // extra parenthesis
struct BOOST_PP_CAT(s, BOOST_PP_DEC(BOOST_PP_ITERATION()) {
// missing a parenthesis
// ...
};
#endif
<pre></div>
</body>
</html>