Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > a question on c++ preprocessor

Reply
Thread Tools

a question on c++ preprocessor

 
 
xin1wang1@yahoo.com
Guest
Posts: n/a
 
      11-05-2006
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?

 
Reply With Quote
 
 
 
 
Greg
Guest
Posts: n/a
 
      11-05-2006
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

 
Reply With Quote
 
 
 
 
Chris Thomasson
Guest
Posts: n/a
 
      11-05-2006
<> wrote in message
news: 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




 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Compiler error occurred when try to use a flexible template expression in preprocessor definesCompiler error occurred when try to use a flexible template expression in preprocessor defines snnn C++ 6 03-14-2005 04:09 PM
preprocessor, token concatenation, no valid preprocessor token Cronus C++ 1 07-14-2004 11:10 PM
a question about preprocessor xuatla C++ 1 07-10-2004 11:03 AM
preprocessor implementation GURU question Dan W. C++ 9 12-04-2003 02:24 AM
Preprocessor's question ³á³á³á³á C Programming 1 09-12-2003 05:32 PM



Advertisments
 



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