one Macro more than one line

Hi,

The compiler reports error with any one Macro more than one line, for
example
#define RIGHT_CHECK(X,Y) ((((int)(X)->centre_right - (int)(Y)->centre_right)
<< :sunglasses: \

  • ((int)(X)->right - (int)(Y)->right))

while following code works:

#define RIGHT_CHECK(X,Y) ((((int)(X)->centre_right - (int)(Y)->centre_right)
<< :sunglasses: + ((int)(X)->right - (int)(Y)->right))

(1) I do not think gnu compiler does not support this.

(2) I do not like to put the macro in one line because there are too many
places and the code is hard to read.

Any solution?

Thanks a lot.

Yiwen

“Yiwen” <ywang@speechworks.com> writes:

The compiler reports error with any one Macro more than one line, for
example
#define RIGHT_CHECK(X,Y) ((((int)(X)->centre_right - (int)(Y)->centre_right)
:sunglasses: > \

  • ((int)(X)->right - (int)(Y)->right))

Hello Yiwen,

I’ve had similar experiences with another compiler in a source-tree
with mixed-up windows and unix lineendings. If the unix compiler
expects the unix lf, but there’s an extra cr it can’t interpret, the
trouble begins…

So check that all source files are stored in unix format. Hope this
helps.

Bye,
~OK~

Oliver Koltermann,

Thanks a lot for your suggestion. You are right.

Hope QNX thinks it is a bug otherwise it is not convinent for customers.

Thanks again!

Yiwen

“Oliver Koltermann” <okoltermann@gmx.de> wrote in message
news:uwujn5sd0.fsf@gmx.de…

“Yiwen” <> ywang@speechworks.com> > writes:

The compiler reports error with any one Macro more than one line, for
example
#define RIGHT_CHECK(X,Y) ((((int)(X)->centre_right -
(int)(Y)->centre_right)
:sunglasses: > \

  • ((int)(X)->right - (int)(Y)->right))

Hello Yiwen,

I’ve had similar experiences with another compiler in a source-tree
with mixed-up windows and unix lineendings. If the unix compiler
expects the unix lf, but there’s an extra cr it can’t interpret, the
trouble begins…

So check that all source files are stored in unix format. Hope this
helps.

Bye,
~OK~

“Yiwen” <ywang@speechworks.com> wrote in message
news:b3iln6$e1e$1@inn.qnx.com…

Oliver Koltermann,

Thanks a lot for your suggestion. You are right.

Hope QNX thinks it is a bug otherwise it is not convinent for customers.

Not a bug at all, just the way UNIX tools versus Windows tools
work. Be sure to run TEXTTO on all files you import from
a Windows system.

(hint: you’ll get this same problem using GNU tools under
Linux and other variations on UNIX, as well).
Randy Hyde

Randy Hyde,

I agree with you if I develop on a Unix/Linux machine. But …

(1) I develop the software on Win2000.
(2) I edit files in QNX Momentics IDE editor. Source code edited by the IDE
itself (not the outside editor) gives the compiling error. It means
non-consistent between IDE and compiler.

So I think it is a bug.

Yiwen

“Randall Hyde” <randall.nospam.hyde@ustraffic.net> wrote in message
news:b3ldhn$hqb$1@inn.qnx.com…

“Yiwen” <> ywang@speechworks.com> > wrote in message
news:b3iln6$e1e$> 1@inn.qnx.com> …
Oliver Koltermann,

Thanks a lot for your suggestion. You are right.

Hope QNX thinks it is a bug otherwise it is not convinent for customers.


Not a bug at all, just the way UNIX tools versus Windows tools
work. Be sure to run TEXTTO on all files you import from
a Windows system.

(hint: you’ll get this same problem using GNU tools under
Linux and other variations on UNIX, as well).
Randy Hyde

Yiwen <ywang@speechworks.com> wrote:

Randy Hyde,

I agree with you if I develop on a Unix/Linux machine. But …

(1) I develop the software on Win2000.
(2) I edit files in QNX Momentics IDE editor. Source code edited by the IDE
itself (not the outside editor) gives the compiling error. It means
non-consistent between IDE and compiler.

So I think it is a bug.

The GNU compiler expects lines to end with ‘\n’. The macro preprocessor
requires the ‘’ character to be the at the end of the line to
escape (kinf of) the line feed character.

I.E. ‘’, ‘\n’, not ‘’, ‘\r’, ‘\n’.

Does your editor have an option to use UNIX style new-lines? Many do.

“Yiwen” <ywang@speechworks.com> wrote in message
news:b3leln$j0h$1@inn.qnx.com…

Randy Hyde,

I agree with you if I develop on a Unix/Linux machine. But …

(1) I develop the software on Win2000.
(2) I edit files in QNX Momentics IDE editor. Source code edited by the
IDE
itself (not the outside editor) gives the compiling error. It means
non-consistent between IDE and compiler.

So I think it is a bug.

Yiwen

No, it is not a bug :slight_smile:
If I were developing on an EBCDIC machine, I couldn’t rightly
expect my text files to work properly under an ASCII system.
This is the same effect.

I, too, develop under Windows.
I use a text editor (CodeWright) that’s smart enough to deal
with different line endings and adjust properly. I’d suggest
you get such an editor (e.g., UltraEdit32, CodeWright,
dozens of others). At some point or another, you’re going
to have a file that contains carriage returns in it; fortunately,
most of these editors contain functions to do the conversion
from one format to another (or you can use TEXTTO under
QNX). That’s just part of life.

If it makes you feel any better, UNIX was using linefeeds
for EOLN well before CP/M-80 came along and used
the two-character sequence . DOS and
Windows, of course, got that sequence from CP/M-80
(whether CP/M-80 inherited it from RSTS or RT-11
is a good question, I don’t remember).

The bottom line is that Windows has a similar “bug”.
Try loading a UNIX text file into notepad.exe and
watch what happens.

To make matters worse, the Macintosh uses single
carriage returns as EOLN markers. So there’s yet
a third type of text data file you’ve got to deal with.
(AFAIK, TEXTTO under QNX doesn’t handle Mac
files, but I’ve got my own version of TEXTTO running
under Windows that deals with all three text file formats).
Randy Hyde

Randall Hyde <randall.nospam.hyde@ustraffic.net> wrote:

(hint: you’ll get this same problem using GNU tools under
Linux and other variations on UNIX, as well).

Not true. I just tried the following example:

#define foo^M
bar^M

gcc 3.2.2 under Linux compiles this without complaints. (It should fail
with a syntax error if the continuation character isn’t recognized.)

-Gerhard

| voice: +43 (0)676 6253725 *** web: http://www.cosy.sbg.ac.at/~gwesp/
|
| Passts auf, seid’s vuasichdig, und lossds eich nix gfoin!
| – Dr. Kurt Ostbahn

Randall Hyde <randall.nospam.hyde@ustraffic.net> wrote:

If it makes you feel any better, UNIX was using linefeeds
for EOLN well before CP/M-80 came along and used
the two-character sequence . DOS and
Windows, of course, got that sequence from CP/M-80
(whether CP/M-80 inherited it from RSTS or RT-11
is a good question, I don’t remember).

I’m pretty sure that this pre-dates any modern OS. It is simply what
is required for older mechanical printers. One character forced the
print head (carrage) to the left hand column and one scrolled the paper
up one line.

Incidenly, it was and not because the carrage return
could be a lengthy operation. So the printer could line feed while
it was still returning the carrage. Many old timers will remember when
software would have to pad tralling s to the because
of the length of time it took to return the carrage.


The bottom line is that Windows has a similar “bug”.
Try loading a UNIX text file into notepad.exe and
watch what happens.

To make matters worse, the Macintosh uses single
carriage returns as EOLN markers. So there’s yet
a third type of text data file you’ve got to deal with.
(AFAIK, TEXTTO under QNX doesn’t handle Mac
files, but I’ve got my own version of TEXTTO running
under Windows that deals with all three text file formats).
Randy Hyde

And hey, QNX 2 used the (Unit Seperator) character for EOL.

–
Bill Caroselli – Q-TPS Consulting
1-(626) 824-7983
qtps@earthlink.net

“Gerhard Wesp” <gwesp@cosy.sbg.ac.at> wrote in message
news:b3vgsv$p7d$1@inn.qnx.com…

Randall Hyde <> randall.nospam.hyde@ustraffic.net> > wrote:
(hint: you’ll get this same problem using GNU tools under
Linux and other variations on UNIX, as well).

Not true. I just tried the following example:

#define foo^M
bar^M

Then this is something they’ve corrected recently…