Hi;
I have this piece of code
It displays this warning on linux:Code:if((p = getenv("LOCATION")) == NULL)
warning: assignment makes pointer from integer without a cast
How do i get rid of this warning?
Thanks
Hi;
I have this piece of code
It displays this warning on linux:Code:if((p = getenv("LOCATION")) == NULL)
warning: assignment makes pointer from integer without a cast
How do i get rid of this warning?
Thanks
It means that 'p' is the wrong type (eg: not a pointer to char).
but i have it defined as
Code:char *p
So that means your compiler thinks getenv returns an int. The reason it thinks so is because you didn't include the header file for getenv.
ok that solves my problem for the warning but why didnt that give me a major error and how did it find the getenv function if i didnt include the header??
You probably included the library with the code, hence it found the function (assuming you mean it ran successfully) -- since C doesn't do any fancy mangling with types, more or less the right thing happened (basically: the string was put on the stack just in case; that's what the function expected, so it ran successfully; and since your architecture apparently has the same size ints as char *s, the return value didn't get mangled either).