要使用与solaris cc-Xa相同的标准,需要使用哪些gcc选项
我需要将大量代码从Solaris迁移到Linux C编译器有Xa选项,这意味着它使用“isoc+K&rccompatibilityextensions” 有一份关于这方面的手册 在Linux上,我有一些在Solaris上没有的关于popen方法的警告:要使用与solaris cc-Xa相同的标准,需要使用哪些gcc选项,c,gcc,std,cc,C,Gcc,Std,Cc,我需要将大量代码从Solaris迁移到Linux C编译器有Xa选项,这意味着它使用“isoc+K&rccompatibilityextensions” 有一份关于这方面的手册 在Linux上,我有一些在Solaris上没有的关于popen方法的警告: toto.c:7: warning: implicit declaration of function 'popen' toto.c:7: warning: assignment makes pointer from integer withou
toto.c:7: warning: implicit declaration of function 'popen'
toto.c:7: warning: assignment makes pointer from integer without a cast
我应该在gcc上使用哪些选项来使用相同的C标准?
没有任何选项或使用-std=gnu89/99,我没有警告
对于-ansi或-std=c89/99,我有警告
使用vanilla或gnu标准来模拟Solaris-Xa选项安全吗
编辑:user31264的toto源代码:
#include <stdio.h>
int main()
{
FILE * FD;
FD = popen("toto", "r");
return 0;
}
您应该在使用it时修复这些警告。如今K&R C只是一个禁区。代码库又大又旧。当然但是我想先让它在Linux中以相同的方式运行,然后更新可以更新的内容。请发布toto.c真正的问题是编译器在任何包含的头中都找不到
popen
的声明。有时它会告诉你(如上所述),或者使用其他选项,它只是默默地编写一个(隐式)声明——这可能是错误的。如前所述,您应该修复该错误…您是否也在从32位(在solaris上)移动到64位(在linux上)?你可能想考虑用2个步骤来做这件事。“无选项”(即默认选项)似乎是正确的选择。如果使用更严格的-std=c90,则需要类似-D_XOPEN_SOURCE=600的东西才能访问popen和其他类似函数。
#if (defined __USE_POSIX2 || defined __USE_SVID || defined __USE_BSD || \
defined __USE_MISC)
/* Create a new stream connected to a pipe running the given command.
This function is a possible cancellation point and therefore not
marked with __THROW. */
extern FILE *popen (__const char *__command, __const char *__modes) __wur;
/* Close a stream opened by popen and return the status of its child.
This function is a possible cancellation point and therefore not
marked with __THROW. */
extern int pclose (FILE *__stream);
#endif