Sun 5.8 C++ errors

Hello,

I got following error messages when I built C++ apps. It was worked before.

...

Error: String/char constants may not include line separator.

...

Error: "," expected instead of "" {"".

...

Error: A declaration was expected instead of "}".

...

Error: There is no prior #if corresponding to this directive.

..

Error: There is no prior #if corresponding to this #endif.

..

C++ version is:

CC: Sun C++ 5.8 Patch 121017-04 2006/08/02

It would be greate appreciated if some one can help on this.

Dol

[602 byte] By [white_face] at [2007-11-26 10:24:21]
# 1
Either predefined macros have been changed or the code has indeed been broken... Can you post the line first error refers to (plus 2-3 lines of code around it) here?
MaximKartashev at 2007-7-7 2:26:21 > top of Java-index,Development Tools,Solaris and Linux Development Tools...
# 2
Thank you for your quickly reply.The C++ apps was built were GNU groff and Berkeley DB with cxx option. The compiler did work before on these apps building. I just upgraded kernel patches (118833-23) and some Sun studio 11 paches a week ago.Any ideas? Thank you.
white_face at 2007-7-7 2:26:21 > top of Java-index,Development Tools,Solaris and Linux Development Tools...
# 3
No, I'm not familiar with GNU groff and Berkeley DB enough so that I can tell what line of their code could make compiler issue the above error messages. Still need to see source code to which error messages refer.
MaximKartashev at 2007-7-7 2:26:21 > top of Java-index,Development Tools,Solaris and Linux Development Tools...
# 4

> I got following error messages when I built C++ apps.

> It was worked before.

> ...

> Error: String/char constants may not include line

> separator.

That message is due to mis-matched quotes, or to a newline inserted inside a string literal. The mis-matched quotes could be caused by not escaping a quote in the string literal. Examples:

"this string is split

across two lines"

"this string has an internal " that is not escaped"

The remaining errors are due to the problem with the string literal.

As to why you are suddenly getting these errors, something in the source code, included headers, or the various software pieces must have changed.

clamage45 at 2007-7-7 2:26:21 > top of Java-index,Development Tools,Solaris and Linux Development Tools...
# 5
I don't think it is codes problem. As if these sources were with g++, no such errors. My question is why Sun C++ (5.8) has weired error messages.Could any body can help this?Thank you very much.
white_face at 2007-7-7 2:26:21 > top of Java-index,Development Tools,Solaris and Linux Development Tools...
# 6

It is not possible to say why you are seeing the error messages without seeing the source code. Try this:

Compile the code as you normally would, but change the -c option to -P. The compiler will produce a .i file, which is the result of preprocessing. Now compile the .i file, and look for the line number where you get the error message about the string constant. If the problem is not obvious, post the part of the code from a few lines before to a few lines after the error message.

As to why the code works with g++ but not Sun C++, it might be due to conditional code in the source that depends on the compiler. If you are compiling Open Source code, it is often the case that the code is customized for different compilers, but not for Sun C++. For example:

#if <gnu>

... declarations

#elif <microsoft>

.. other declarat ions

#elif <macintosh>

.. still other declarations

#endif

// oops, no declarations for Sun C++

clamage45 at 2007-7-7 2:26:21 > top of Java-index,Development Tools,Solaris and Linux Development Tools...
# 7

Thanks all,

The issue has solved. It is pretty interesting. First I followed the guys suggestions, I did:

1. I found added a new line at end of those files which error messages on. Then remade to build C++ apps. Everything was fine. Also, I deleted a new line at end of thoes files, remade was fine.

2. I remkfsed a file system with default, where apps were located. (previous file system was made with newfs -f 2048). Then rebuilt these C++ apps successful without modfications on those files. Is the issue is related fragsize of file system?

Thank you for all your replies.

white_face at 2007-7-7 2:26:21 > top of Java-index,Development Tools,Solaris and Linux Development Tools...