[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: [OT] gcc-warnings



* Daniel Reuter <reuter@Uni-Hohenheim.DE>
>
> Hello there,
> 
> I never quite understood the following warning message from gcc:
> 
> sourcefile.c: linenumber: warning: assignment makes pointer from integer
> without a cast
> 
> Unfortunately, I couldn't find a pointer on warning messages in the
> gcc-doc.
> Perhaps someone could enlighten me. Thanks.

As others have pointed out, this means exactly what it says: you're
trying to assign a integer value to a pointer variable.  However, I've
find that this most often happens when one tries to use a function which
hasn't been declared.  Without a proper function prototype, your C
compiler will assume that the function returns int.

Consider, for instance the following program:

int
main(void)
{
	char *p = strdup("fisk");
	return 0;
}

When compiling this, you will get the above error, since the code does
not

#include <string.h>

-- 
Kjetil



Reply to: