You must have a main() function in your program. That's the entry point. If there's no entry point provided, then your program doesn't do anything, no matter how long code you have written.
sleep() takes an unsigned int for an argument, but you're giving it a double (0.5), which is cast to int and turned into 0.
Your code correctly:
#include <stdio.h>
#include <unistd.h>
int function()
{
int led = 1;
while (true)
{
printf("led: %d\n", led);
sleep(1);
led = !led;
}
return 0;
}
int main()
{
return function();
}