1
我想摆脱警告。当我与警告:隐式声明函数'getresuid'(和'seteuid')
gcc -Wall -ansi -o test test.c
编译源代码,我回去
test.c: In function ‘main’:
test.c:12: warning: implicit declaration of function ‘getresuid’
test.c:14: warning: implicit declaration of function ‘seteuid’
当我编译它没有-ansi开关
gcc -Wall -o test test.c
我在终端
test.c: In function ‘main’:
test.c:12: warning: implicit declaration of function ‘getresuid’
看
我想用-ansi切换并摆脱警告。我怎样才能实现我的目标?
/* this is the test.c */
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
#define __USE_GNU 1
#define __USE_BSD 1
int main()
{
static uid_t euid, ruid, suid;
getresuid(&ruid, &euid, &suid);
seteuid(getuid());
return 0;
}
环境:
的CentOS 6.3 32位
gcc版本4.4.7 20120313(红帽4.4.7-3)(GCC)
我已添加(实施)由俞灏提出的解决方案。最初的文章反映了变化 – Igor
我已经删除了您添加的解决方案部分,因为这不是如何工作,您应该保持原样。 –
@俞皓好吧,我注意到你已经从我的帖子中删除了详细的解决方案。老实说,我不明白__why__。我没有修改最初的帖子,我只是添加了解决方案。既然,我是C新手,我认为一个详细的解决方案可以帮助其他新手。人们喜欢通过示例来学习,例如,看到“错误”的方法,然后是“正确的”版本。它缩短了学习。但是,正如我现在看到的那样,这不被推荐。我可以忍受这一点。 – Igor