ClassCertificates #include stdlib.h not clearing warning


I’ve included stdlib.h in the example code but am still getting the invalid implicit declaration warning on the first sleep(2) statement.

Here is my code:

[code]#include <stdio.h>
#include <stdlib.h>

void congratulateSudent(char *student, char *course, int numdays)
printf("%s has done as much %s programming as I could fit into %d days.\n", student, course, numdays);

int main (int argc, const char * argv[])

// insert code here...
printf("Hello, World!\n");

congratulateSudent("Mark", "Cocoa", 5);
congratulateSudent("Bo", "Objective-C", 2);
congratulateSudent("Eric", "Zen", 1);
congratulateSudent("Jane", "C", 3);

return 0;


What am I missing?

Running Xcode 4.2.


Hi Community this is my first post on this Forum

Just read on like i do :wink:

Weiterlesen hilft wie bei mir :wink:



As declared later in the book, this is what usually happens, you should ignore the error.

Hamburg, die schönste Stadt der Welt <3


If you look at the docs for the function, you can see that you should include unistd.h. I don’t know if the sleep function in earlier Xcode versions was declared in stdlib.h but in Xcode 4.2 you should use unistd.h to get rid of the warning.


@rohdester - unistd.h got rid of the warning. Thanks.


Also for 4.1 you need to include unistd.h, not sure about earlier versions, but probably not a lot of people will use older Xcode versions anyway.


@rohdester – Thanks for the tip!


I’m not sure if it’s a good idea, but changing the C Language Dialect (under Build All) to ANSI-C from GNU-99 clears the warning.


I too was curious as to why I was receiving an Implicit Declaration.

As mentioned earlier by @rohdester The sleep function looks to be declared in unistd.h

Replacing #include <stdlib.h> with #include <unistd.h> resolved the issue.