wrote:
> I have just checked the faq and some refs on my bookshelf, but fail to
> find an answer to my following question:
>
> I am developing a code generator which generates c++ code from some
> interface definitions (xml) .... The generated code needs to be
> compiled against some other manully written code. If some prototype
> mis-match between the generated code and the manul code, I would like
> the compiler to report the problem by pointing out the location of the
> problematic interface definition in the xml file, rather than reporting
> error (prototype mismatch) pointing to the generated c++ file.
>
> I guess I can do this by inserting
>
> # <line> "<text>" <list of numbers>
No, the supported syntax for the #line directive is:
#line <digit-sequence> "<s-char-sequence>"
The digit-sequence specifies the new line number (which is stored in
the predefined macro: __LINE__). The optional char-sequence within
quotes specifies the new source file name (which is kept in the
predefined macro: __FILE__).
> My questions are:
>
> 1. whether this is portable, as I don't want the geneated code to be
> platform dependent.
The #line directive has been part of C++ and C since well before either
language was a standard. So I can't imagine any likely portability
issues with its use.
> 2. what is the <list of numbers>'s standard format and usefulness?
See above or refer to §16.4 of the C++ Standard for the syntax of a
#line directive. Note that it is legal to use macros in a #line
directive just as long as the result of their expansiion is a valid
#line directive shown above - otherwise the behavior of the #line
directive is formally, undefined.
Greg