小编Igo*_*gor的帖子

警告:隐式声明函数'getresuid'(和'seteuid')

我想摆脱警告.当我编译源代码时

gcc -Wall -ansi -o test test.c  
Run Code Online (Sandbox Code Playgroud)

我回来了

test.c: In function ‘main’:
test.c:12: warning: implicit declaration of function ‘getresuid’
test.c:14: warning: implicit declaration of function ‘seteuid’
Run Code Online (Sandbox Code Playgroud)

当我编译它没有-ansi开关

gcc -Wall -o test test.c 
Run Code Online (Sandbox Code Playgroud)

我在终端上看到了

test.c: In function ‘main’:
test.c:12: warning: implicit declaration of function ‘getresuid’
Run Code Online (Sandbox Code Playgroud)

我想用-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 …
Run Code Online (Sandbox Code Playgroud)

c linux gcc compiler-warnings gcc-warning

3
推荐指数
1
解决办法
5039
查看次数

标签 统计

c ×1

compiler-warnings ×1

gcc ×1

gcc-warning ×1

linux ×1