BOOST_PP_LINE

The BOOST_PP_LINE macro places notes encoded as line directives in the preprocessing output.

#### Usage

#line BOOST_PP_LINE(line, file)

#### Arguments

line
  The new line number of the trailing line. The predefined macro __LINE__ is commonly used.
file
  Typically the name of the current file. However, any informative text will work. This text is internally stringized, so quotation marks are unnecessary.

#### Remarks

If the macro BOOST_PP_CONFIG_EXTENDED_LINE_INFO is defined as 1 and a file-iteration is in progress, this macro will automatically insert debugging information about the state of file-iteration. This information will show the all of the current iteration values with the inner most iteration last.
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:
"file.hpp", line 2: error: expected a ";"
"file.hpp", line 4: error: improperly terminated macro invocation
You might get something like this instead....
"file.hpp [1]", line 2: error: expected a ";"
"file.hpp [5]", line 4: error: improperly terminated macro invocation
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.
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 BOOST_PP_CONFIG_EXTENDED_LINE_INFO to 1 only when debugging.

#### See Also

- BOOST_PP_CONFIG_EXTENDED_LINE_INFO

#### Requirements

Header: <boost/preprocessor/debug/line.hpp>

#### Sample Code

    // 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

© Copyright Housemarque Oy 2002 © Copyright Paul Mensonides 2002

Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at www.boost.org/LICENSE_1_0.txt)