jordanmthomas
September 6th, 2007, 01:27 AM
I'm writing a shell for a school assignment in c, and it has to compile without any warnings. To get the current directory, I am using get_current_dir_name.
Here's what I think is the relevant code (snipped up for clarity):
#include <unistd.h>
int main(int argc, char** argv)
{
char* cwd = (char*)get_current_dir_name();
}
When I compile, this warning is given:
jshell.c:19: warning: implicit declaration of function ‘get_current_dir_name’
I don't understand why this is happening because according to man get_current_dir_name, I should just have to include unistd.h
man get_current_dir_name
...SYNOPSIS
#include <unistd.h>
...
...
char *get_current_dir_name(void);
The code works fine, but I don't know how to get rid of the warning. Any help is appreciated. I'm sure it's something stupid on my part, but I can't figure it out.
Thanks in advance.
**edit** This warning doesn't come up if I don't use -Wall when compiling, but I am required to use it :).
**edit2** Using other functions from unistd.h does not result in the warning.
Here's what I think is the relevant code (snipped up for clarity):
#include <unistd.h>
int main(int argc, char** argv)
{
char* cwd = (char*)get_current_dir_name();
}
When I compile, this warning is given:
jshell.c:19: warning: implicit declaration of function ‘get_current_dir_name’
I don't understand why this is happening because according to man get_current_dir_name, I should just have to include unistd.h
man get_current_dir_name
...SYNOPSIS
#include <unistd.h>
...
...
char *get_current_dir_name(void);
The code works fine, but I don't know how to get rid of the warning. Any help is appreciated. I'm sure it's something stupid on my part, but I can't figure it out.
Thanks in advance.
**edit** This warning doesn't come up if I don't use -Wall when compiling, but I am required to use it :).
**edit2** Using other functions from unistd.h does not result in the warning.