1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
<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.
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.html"><boost/preprocessor/debug/line.hpp></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 <<a href="../headers/arithmetic/dec.html">boost/preprocessor/arithmetic/dec.hpp</a>>
#include <<a href="../headers/cat.html">boost/preprocessor/cat.hpp</a>>
#include <<a href="../headers/debug/line.html">boost/preprocessor/debug/line.hpp</a>>
#include <<a href="../headers/iteration/iterate.html">boost/preprocessor/iteration/iterate.hpp</a>>
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>© Copyright <a href="http://www.housemarque.com" target="_top">Housemarque Oy</a> 2002</i>
</br><i>© 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>
|