Hi,
I'm tying to use the following function to reboot the system as part of my code
#include <unistd.h>
#include <linux/reboot.h>
int restart(unsigned int delay)
{
sleep(delay);
return reboot(LINUX_REBOOT_CMD_RESTART);
}
When I try to compile the code I get the warning in the thread topic. However the code compiles and runs just fine. Flexelint also picks up the warning with the following message:
Info 718: reboot undeclared, assumed to return int
Info 746: Call to function 'reboot' not made in the presence of a prototype
Nothing is wrong. Your compilers are trying to "help" you by warning you of using function calls that have not properly been defined. Apparently, the linux/reboot.h header file doesn't include a function definition for reboot. You can fix this with:
#include <unistd.h>
#include <linux/reboot.h>
int reboot(int);
int restart(unsigned int delay)
{
sleep(delay);
return reboot(LINUX_REBOOT_CMD_RESTART);
}
Thanks. I looked at the linux/reboot.h header file and indeed there's no reboot definition. However the sys/reboot.h header file holds the definition so I've included that as well and now it works.