mirror of
https://github.com/boostorg/preprocessor.git
synced 2025-07-29 11:47:14 +02:00
initial revision
[SVN r15198]
This commit is contained in:
103
docs.1/ref/line.html
Normal file
103
docs.1/ref/line.html
Normal file
@ -0,0 +1,103 @@
|
||||
<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.
|
||||
The predefined macro <i>__LINE__</i> is commonly used.
|
||||
</dd>
|
||||
<dt>file</dt>
|
||||
<dd>
|
||||
Typically the name of the current file.
|
||||
However, any informative text will work.
|
||||
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>.
|
||||
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.
|
||||
Finding any errors is sometimes less than straightforward.
|
||||
Use of this macro can provide information to make this much easier.
|
||||
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.
|
||||
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.
|
||||
Those compilers typically issues warnings about the bad filename.
|
||||
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> <a href="../headers/debug/line.hpp.html"><boost/preprocessor/debug/line.hpp></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 <boost/preprocessor/arithmetic/dec.hpp>
|
||||
#include <boost/preprocessor/cat.hpp>
|
||||
#include <boost/preprocessor/debug/line.hpp>
|
||||
#include <boost/preprocessor/iteration/iterate.hpp>
|
||||
|
||||
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>
|
Reference in New Issue
Block a user