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]

# 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.
# 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++
# 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.