不能在Solaris </stdlib.h>上#include <stdlib.h>

时间:2011-04-14 02:08:49

标签: solaris

我正在使用Solaris x86并使用OpenCSW软件包安装了gcc4。下面的简单测试程序将无法编译:

#include <stdio.h>
#include <stdlib.h>

main()
{
   printf("Hello, world\n");
}

如果我没有stdlib.h include,它会构建并运行良好。当stdlib.h在我时,我得到以下错误:

bash-3.00$ g++ -I/opt/csw/include test.cpp
In file included from /opt/csw/gcc4/lib/gcc/i386-pc-solaris2.8/4.3.3/include-    fixed/stdlib.h:27,
                 from test.cpp:2:
/usr/include/iso/stdlib_iso.h:107: error: expected initializer before '__NORETURN'
/usr/include/iso/stdlib_iso.h:124: error: expected initializer before '__NORETURN'
/usr/include/iso/stdlib_iso.h:132: error: multiple parameters named '_RESTRICT_KYWD'

我认为这可能是OpenCSW和默认库之间的某种冲突,但我不确定如何修复它。有人可以帮忙吗?

3 个答案:

答案 0 :(得分:1)

只需从命令行中删除-I/opt/csw/include

答案 1 :(得分:1)

尝试运行应该成为gcc安装一部分的fixheadersfixincludes命令之一。根据其名称为Solaris 8构建的gcc软件包与您正在运行的Solaris发行版(可能是Solaris 10或更高版本)之间可能存在不匹配。

答案 2 :(得分:0)

无法在没有-I的情况下在Solaris 10 x86上重现:

-bash-3.00$ /opt/csw/gcc4/bin/g++ test.cpp
-bash-3.00$ /opt/csw/gcc4/bin/g++ -v    
Using built-in specs.
Target: i386-pc-solaris2.10
Configured with: ../gcc-4.3.3/configure --prefix=/opt/csw/gcc4 --exec-prefix=/opt/csw/gcc4 --with-gnu-as --with-as=/opt/csw/bin/gas --without-gnu-ld --with-ld=/usr/ccs/bin/ld --enable-nls --with-included-gettext --with-libiconv-prefix=/opt/csw --with-x --with-mpfr=/opt/csw --with-gmp=/opt/csw --enable-java-awt=xlib --enable-libada --enable-libssp --enable-objc-gc --enable-threads=posix --enable-stage1-languages=c --enable-languages=ada,c,c++,fortran,java,objc
Thread model: posix
gcc version 4.3.3 (GCC)