[cs631apue] non-homework: welcome.c

Jan Schaumann jschauma at stevens.edu
Sun Sep 14 14:46:57 EDT 2014

sshah83 <sshah83 at stevens.edu> wrote:

> The second warning is about int being used as char* which implies wrong  
> type returned by getlogin() function.
> If I turn on all warnings using below command :
> gcc -Wall welcome.c -o welcome.out
> I see the exact warning leading to the implicit function declaration
> welcome.c:5:2: warning: implicit declaration of function 'getlogin'  
> [-Wimplicit-function-declaration]
> This warning means function prototype for getlogin() is missing and the  
> "implicit function declaration" rule in C language means that a default  
> declaration that returns int is created implicitly  
> (http://stackoverflow.com/questions/9182763/implicit-function-declarations-in-c).
> The fix would be to include the correct header file which has the right  
> function prototype
> #include <unistd.h>

Correct - well done!

Compiling with "-Wall" is always a good idea, but mandatory in this
class.  Reading and understanding the messages the compiler gives you
allows you to quickly fix these sorts of things.


More information about the cs631apue mailing list