By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,851 Members | 2,097 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,851 IT Pros & Developers. It's quick & easy.

a question on c++ preprocessor

P: n/a
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>

in the generating C++ code. This causes the c++ compiler to report the
error as:

<text>:<line+delta....

My questions are:

1. whether this is portable, as I don't want the geneated code to be
platform dependent.
2. what is the <list of numbers>'s standard format and usefulness?

Nov 5 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
xi*******@yahoo.com 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

Nov 5 '06 #2

P: n/a
<xi*******@yahoo.comwrote in message
news:11**********************@m73g2000cwd.googlegr oups.com...
>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) ....
Check this crap out:

http://groups.google.com/group/comp....382dc9a40439c7

:O


Nov 5 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.