I would like to get rid of the warnings. When I compile the source code with
gcc -Wall -ansi -o test test.c
I get back
test.c: In function ‘main’:
test.c:12: warning: implicit declaration of function ‘getresuid’
test.c:14: warning: implicit declaration of function ‘seteuid’
When I compile it without -ansi switch
gcc -Wall -o test test.c
I see on the terminal
test.c: In function ‘main’:
test.c:12: warning: implicit declaration of function ‘getresuid’
I would like to use -ansi switch and get rid of warnings. How can I achieve my goal ?
/* 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;
}
Environment:
CentOS 6.3 32-bit
gcc version 4.4.7 20120313 (Red Hat 4.4.7-3) (GCC)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…