1 | <html> |
---|
2 | <head> |
---|
3 | <title>BOOST_PP_LINE</title> |
---|
4 | <link rel="stylesheet" type="text/css" href="../styles.css"> |
---|
5 | </head> |
---|
6 | <body> |
---|
7 | <div style="margin-left: 0px;"> |
---|
8 | The <b>BOOST_PP_LINE</b> macro places notes encoded as line directives in the preprocessing output. |
---|
9 | </div> |
---|
10 | <h4>Usage</h4> |
---|
11 | <div class="code"> |
---|
12 | #line <b>BOOST_PP_LINE</b>(<i>line</i>, <i>file</i>) |
---|
13 | </div> |
---|
14 | <h4>Arguments</h4> |
---|
15 | <dl> |
---|
16 | <dt>line</dt> |
---|
17 | <dd> |
---|
18 | The new line number of the trailing line. |
---|
19 | The predefined macro <i>__LINE__</i> is commonly used. |
---|
20 | </dd> |
---|
21 | <dt>file</dt> |
---|
22 | <dd> |
---|
23 | Typically the name of the current file. |
---|
24 | However, any informative text will work. |
---|
25 | This text is internally stringized, so quotation marks are unnecessary. |
---|
26 | </dd> |
---|
27 | </dl> |
---|
28 | <h4>Remarks</h4> |
---|
29 | <div> |
---|
30 | If the macro <b>BOOST_PP_CONFIG_EXTENDED_LINE_INFO</b> is defined as <i>1</i> and a <i>file-iteration</i> |
---|
31 | is in progress, this macro will automatically insert debugging information about the state of <i>file-iteration</i>. |
---|
32 | This information will show the all of the current iteration values with the inner most iteration last. |
---|
33 | </div> |
---|
34 | <div> |
---|
35 | This information is useful when errors might be spanning multiple iterations of the same source text. |
---|
36 | Finding any errors is sometimes less than straightforward. |
---|
37 | Use of this macro can provide information to make this much easier. |
---|
38 | For example, instead of getting several errors like this: |
---|
39 | <div><i> |
---|
40 | "file.hpp", line 2: error: expected a ";"<br> |
---|
41 | "file.hpp", line 4: error: improperly terminated macro invocation<br> |
---|
42 | </i></div> |
---|
43 | You might get something like this instead.... |
---|
44 | <i><div> |
---|
45 | "file.hpp [1]", line 2: error: expected a ";"<br> |
---|
46 | "file.hpp [5]", line 4: error: improperly terminated macro invocation<br> |
---|
47 | </i></div> |
---|
48 | It is immediately evident that this error is spanning multiple iterations of the same source text. |
---|
49 | If it wasn't, the same errors would occur on each iteration. |
---|
50 | </div> |
---|
51 | <div> |
---|
52 | It must be noted however, that some compilers don't like filenames that aren't actually files. |
---|
53 | Those compilers typically issues warnings about the bad filename. |
---|
54 | 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. |
---|
55 | </div> |
---|
56 | <h4>See Also</h4> |
---|
57 | <ul> |
---|
58 | <li><a href="config_extended_line_info.html">BOOST_PP_CONFIG_EXTENDED_LINE_INFO</a></li> |
---|
59 | </ul> |
---|
60 | <h4>Requirements</h4> |
---|
61 | <div> |
---|
62 | <b>Header:</b> <a href="../headers/debug/line.html"><boost/preprocessor/debug/line.hpp></a> |
---|
63 | </div> |
---|
64 | <h4>Sample Code</h4> |
---|
65 | <div><pre> |
---|
66 | // sample.cpp |
---|
67 | #if !defined(<a href="is_iterating.html">BOOST_PP_IS_ITERATING</a>) |
---|
68 | |
---|
69 | #define <a href="config_extended_line_info.html">BOOST_PP_CONFIG_EXTENDED_LINE_INFO</a> 1 |
---|
70 | |
---|
71 | #include <<a href="../headers/arithmetic/dec.html">boost/preprocessor/arithmetic/dec.hpp</a>> |
---|
72 | #include <<a href="../headers/cat.html">boost/preprocessor/cat.hpp</a>> |
---|
73 | #include <<a href="../headers/debug/line.html">boost/preprocessor/debug/line.hpp</a>> |
---|
74 | #include <<a href="../headers/iteration/iterate.html">boost/preprocessor/iteration/iterate.hpp</a>> |
---|
75 | |
---|
76 | namespace sample { |
---|
77 | |
---|
78 | #define <a href="iteration_params_x.html">BOOST_PP_ITERATION_PARAMS_1</a> (3, (1, 5, "sample.cpp")) |
---|
79 | #include <a href="iterate.html">BOOST_PP_ITERATE</a>() |
---|
80 | |
---|
81 | } // sample |
---|
82 | |
---|
83 | int main(void) { |
---|
84 | return 0; |
---|
85 | } |
---|
86 | |
---|
87 | #else |
---|
88 | |
---|
89 | #line <a href="line.html">BOOST_PP_LINE</a>(1, sample.cpp) |
---|
90 | |
---|
91 | int <a href="cat.html">BOOST_PP_CAT</a>(x, <a href="iteration.html">BOOST_PP_ITERATION</a>())); // extra parenthesis |
---|
92 | |
---|
93 | 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>()) { |
---|
94 | // missing a parenthesis |
---|
95 | // ... |
---|
96 | }; |
---|
97 | |
---|
98 | #endif |
---|
99 | </pre></div> |
---|
100 | <hr size="1"> |
---|
101 | <div style="margin-left: 0px;"> |
---|
102 | <i>© Copyright <a href="http://www.housemarque.com" target="_top">Housemarque Oy</a> 2002</i> |
---|
103 | </br><i>© Copyright Paul Mensonides 2002</i> |
---|
104 | </div> |
---|
105 | <div style="margin-left: 0px;"> |
---|
106 | <p><small>Distributed under the Boost Software License, Version 1.0. (See |
---|
107 | accompanying file <a href="../../../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> or |
---|
108 | copy at <a href= |
---|
109 | "http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</a>)</small></p> |
---|
110 | </div> |
---|
111 | </body> |
---|
112 | </html> |
---|