compiling issue with sun studio 11

I am am trying to compile an application on Solaris 11 x86 using sun studio 11 compiler suite. I get the following errors when I compile a file called Terminal.cpp.

<snip>

"../libs/libFreeMat/Types.hpp", line 56: Warning: Identifier expected instead of "}".

"/usr/include/curses.h", line 141: Warning (Anachronism): Attempt to redefine TRUE without using #undef.

"Terminal.cpp", line 238: Warning (Anachronism): Formal argument 3 of type extern "C" int(*)(char) in call to tputs(char*, int, extern "C" int(*)(char)) is being passed int(*)(char).

"Terminal.cpp", line 246: Warning (Anachronism): Formal argument 3 of type extern "C" int(*)(char) in call to tputs(char*, int, extern "C" int(*)(char)) is being passed int(*)(char).

"Terminal.cpp", line 254: Warning (Anachronism): Formal argument 3 of type extern "C" int(*)(char) in call to tputs(char*, int, extern "C" int(*)(char)) is being passed int(*)(char).

"Terminal.cpp", line 262: Warning (Anachronism): Formal argument 3 of type extern "C" int(*)(char) in call to tputs(char*, int, extern "C" int(*)(char)) is being passed int(*)(char).

"Terminal.cpp", line 270: Warning (Anachronism): Formal argument 3 of type extern "C" int(*)(char) in call to tputs(char*, int, extern "C" int(*)(char)) is being passed int(*)(char).

"Terminal.cpp", line 278: Warning (Anachronism): Formal argument 3 of type extern "C" int(*)(char) in call to tputs(char*, int, extern "C" int(*)(char)) is being passed int(*)(char).

"/opt/SUNWspro/prod/include/CC/Cstd/./list.cc", line 84: Warning: Too many arguments in macro erase.

"/opt/SUNWspro/prod/include/CC/Cstd/./list.cc", line 97: Warning: Too many arguments in macro erase.

"/opt/SUNWspro/prod/include/CC/Cstd/./list.cc", line 136: Warning: Too many arguments in macro erase.

"/opt/SUNWspro/prod/include/CC/Cstd/./list.cc", line 136: Error: werase is not a member of std::list<std::T, std::Allocator>.

"/opt/SUNWspro/prod/include/CC/Cstd/./list.cc", line 139: Error: A declaration was expected instead of "while".

"/opt/SUNWspro/prod/include/CC/Cstd/./list.cc", line 139: Error: No direct declarator preceding "(".

"/opt/SUNWspro/prod/include/CC/Cstd/./list.cc", line 141: Warning: Too many arguments in macro erase.

"/opt/SUNWspro/prod/include/CC/Cstd/./list.cc", line 144: Error: A declaration was expected instead of "}".

"/opt/SUNWspro/prod/include/CC/Cstd/./list.cc", line 147: Error: Templates can only declare classes or functions.

"/opt/SUNWspro/prod/include/CC/Cstd/./list.cc", line 152: Error: iterator is not defined.

"/opt/SUNWspro/prod/include/CC/Cstd/./list.cc", line 152: Error: The function "end" must have a prototype.

"/opt/SUNWspro/prod/include/CC/Cstd/./list.cc", line 153: Error: const_iterator is not defined.

"/opt/SUNWspro/prod/include/CC/Cstd/./list.cc", line 153: Error: x is not defined.

"/opt/SUNWspro/prod/include/CC/Cstd/./list.cc", line 153: Error: Badly formed expression.

"/opt/SUNWspro/prod/include/CC/Cstd/./list.cc", line 154: Error: const_iterator is not defined.

"/opt/SUNWspro/prod/include/CC/Cstd/./list.cc", line 154: Error: x is not defined.

"/opt/SUNWspro/prod/include/CC/Cstd/./list.cc", line 154: Error: Badly formed expression.

"/opt/SUNWspro/prod/include/CC/Cstd/./list.cc", line 155: Error: A declaration was expected instead of "while".

"/opt/SUNWspro/prod/include/CC/Cstd/./list.cc", line 155: Error: No direct declarator preceding "(".

"/opt/SUNWspro/prod/include/CC/Cstd/./list.cc", line 156: Error: No direct declarator preceding "(".

"/opt/SUNWspro/prod/include/CC/Cstd/./list.cc", line 157: Warning: Too many arguments in macro erase.

"/opt/SUNWspro/prod/include/CC/Cstd/./list.cc", line 160: Error: A declaration was expected instead of "}".

"/opt/SUNWspro/prod/include/CC/Cstd/./list.cc", line 161: Error: A declaration was expected instead of "return".

"/opt/SUNWspro/prod/include/CC/Cstd/./list.cc", line 161: Error: There must be an identifier to declare.

"/opt/SUNWspro/prod/include/CC/Cstd/./list.cc", line 165: Error: Templates can only declare classes or functions.

"/opt/SUNWspro/prod/include/CC/Cstd/./list.cc", line 168: Error: iterator is not defined.

"/opt/SUNWspro/prod/include/CC/Cstd/./list.cc", line 168: Error: The function "end" must have a prototype.

"/opt/SUNWspro/prod/include/CC/Cstd/./list.cc", line 169: Error: A declaration was expected instead of "while".

"/opt/SUNWspro/prod/include/CC/Cstd/./list.cc", line 169: Error: No direct declarator preceding "(".

"/opt/SUNWspro/prod/include/CC/Cstd/./list.cc", line 173: Error: A declaration was expected instead of "if".

Compilation aborted, too many Error messages.

*** Error code 1

make: Fatal error: Command failed for target `Terminal.o'

</snip>

These are the includes for that file.

<snip>

#include <qapplication.h>

#include "Serialize.hpp"

#include "Terminal.hpp"

#include <errno.h>

#include <unistd.h>

#include <stdio.h>

#include <stdlib.h>

#include <string.h>

#ifdef Q_WS_X11

#include <curses.h>

#include <term.h>

#include <curses.h>

#include <string>

#include <sys/ioctl.h>

#include "Exception.hpp"

#include <sys/types.h>

#include <sys/stat.h>

#include <dirent.h>

#include <glob.h>

</snip>

Have I missed out and file to include. Apparently it compiles in Linux.

[5711 byte] By [jeevan.kr] at [2007-11-26 11:54:47]
# 1

Some likely possibilities:

1. If this is open source code, you may be running into a configuration issue. Open Source code often has #if-#elseif blocks conditionalized on various OS and compiler versions that usually do not consider Sun compilers on Solaris. So you wind up with missing declarations, or fall through to inappropriate source code.

2. The code depends on features of the C++ Standard Library that are not supported by the default libCstd. Refer to the Sun C++ FAQ for details:

http://developers.sun.com/sunstudio/documentation/ss11/mr/READMEs/c++_faq.html# LibComp

3. The code depends on non-standard extensions in gcc or the Gnu version of the C++ standard library.

The fix for #2 is usually to use the optional STLport version of the standard library that is supplied with Sun Studio. Add the option

-library=stlport4

to every CC command, compiling and linking.

The fix for #3 might be addressed by the fix for #1, assuming the code is intended for porting to different environments.

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

> I am am trying to compile an application on Solaris

> 11 x86 using sun studio 11 compiler suite. I get the

> following errors when I compile a file called

> Terminal.cpp.

>

> <snip>

> "../libs/libFreeMat/Types.hpp", line 56: Warning:

> Identifier expected instead of "}".

Can you post the lines around line 56 of libs/libFreeMat/Types.hpp?

Are you compiling for x86 or amd64?

There's a good chance that if you solve this, the other errors will go away.

> These are the includes for that file.

> <snip>

> #include <qapplication.h>

<snip>

> #ifdef Q_WS_X11

So this is a Qt app. I worked a lot with Qt in my previous job, and had no problems with it on SPARC or x86. I only used it a very little with amd64.

Paul

Paul_Floyd at 2007-7-7 12:12:49 > top of Java-index,Development Tools,Solaris and Linux Development Tools...
# 3

Hi Stephen,

I tried the #2 fix that you suggested, and it got rid of the list.cc errors. However, I am stuck with another error.

CC -DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE=\"FreeMat\" -DVERSION=\"2.0\" -DYYTEXT_POINTER=1 -DHAVE_CURSES_H=1 -I. -I. -I../libs/libFreeMat -I../libs/libMex -I../libs/libXP -I../libs/libCore -I../libs/libGraphics -I../libs/libFN -I../src -DQT_SHARED -I/usr/local/Trolltech/Qt-4.2.1/include -I/usr/local/Trolltech/Qt-4.2.1/include/QtCore -I/usr/local/Trolltech/Qt-4.2.1/include/QtGui -I/usr/local/Trolltech/Qt-4.2.1/include/QtOpenGL -I/space/downloads/freemat/FreeMat-2.0/extern/Root/include -DBASEPATH=\"../share/FreeMat-2.0\" -g -I/space/downloads/freemat/FreeMat-2.0/extern/Root/include -library=stlport4 -c -o Terminal.o Terminal.cpp

[b]"/opt/SUNWspro/prod/include/CC/stlport4/stl/_stdio_file.h", line 97: Error: _file is not a member of const __FILE.[/b]

"/usr/include/curses.h", line 141: Warning (Anachronism): Attempt to redefine TRUE without using #undef.

"Terminal.cpp", line 238: Warning (Anachronism): Formal argument 3 of type extern "C" int(*)(char) in call to tputs(char*, int, extern "C" int(*)(char)) is being passed int(*)(char).

"Terminal.cpp", line 246: Warning (Anachronism): Formal argument 3 of type extern "C" int(*)(char) in call to tputs(char*, int, extern "C" int(*)(char)) is being passed int(*)(char).

"Terminal.cpp", line 254: Warning (Anachronism): Formal argument 3 of type extern "C" int(*)(char) in call to tputs(char*, int, extern "C" int(*)(char)) is being passed int(*)(char).

"Terminal.cpp", line 262: Warning (Anachronism): Formal argument 3 of type extern "C" int(*)(char) in call to tputs(char*, int, extern "C" int(*)(char)) is being passed int(*)(char).

"Terminal.cpp", line 270: Warning (Anachronism): Formal argument 3 of type extern "C" int(*)(char) in call to tputs(char*, int, extern "C" int(*)(char)) is being passed int(*)(char).

"Terminal.cpp", line 278: Warning (Anachronism): Formal argument 3 of type extern "C" int(*)(char) in call to tputs(char*, int, extern "C" int(*)(char)) is being passed int(*)(char).

1 Error(s) and 7 Warning(s) detected.

Is there a workaround for that ?

Thanks for the help!

jeevankr at 2007-7-7 12:12:49 > top of Java-index,Development Tools,Solaris and Linux Development Tools...
# 4
Thanks Paul, I got rid of the warning in Types.hpp ( just an extra comma lying around). But, I used Stephens suggestion and got rid of most of the errors , and am now faced with a new one. take a look in the above post.
jeevankr at 2007-7-7 12:12:49 > top of Java-index,Development Tools,Solaris and Linux Development Tools...
# 5

Hi

The error looks like it is due to direct manipulation of the internals of struct FILE:

inline int_FILE_fd(const FILE *__f) { return __f->_file; }

My guess is that you have a

#define FILE __FILE somewhere, and __FILE is not compatible with the standard C FILE defined in stdio.h

You also have some warnings due to the use of pointers to "C" functions being passed pointers to "C++" functions. Often wrapping a #include in 'extern "C" {' and '}' does the trick.

Paul

Paul_Floyd at 2007-7-7 12:12:49 > top of Java-index,Development Tools,Solaris and Linux Development Tools...
# 6
I'm handling these issues with Jeevan off line.
clamage45 at 2007-7-7 12:12:49 > top of Java-index,Development Tools,Solaris and Linux Development Tools...