warning: assignment makes pointer from integer without a cast
I did not care on warnings. But they put me in trouble lately.
When compiler comes to the statement below it gives the warning.
/* void ** vpSec00 comes as an argument */
int hSec = 0;
size_t nbytes;
*vpSec00 = bitio_o_close(hSec0, &nbytes);
it says:
warning: assignment makes pointer from integer without a cast
if i cast it as :
/* void ** vpSec00 comes as an argument */
*vpSec00 = (void *) bitio_o_close(hSec0, &nbytes);
it says:
warning: cast to pointer from integer of different size
bitio_o_close function returns char array as:
return (void *) bios[handle].buf;
why would i need casting here? Because Salem said that I should stay away from redundant casting in function returns.
asilter
Junior Poster in Training
60 posts since Oct 2006
Reputation Points: 10
Solved Threads: 0
Compiled without errors/warnings with my compiler -- VC++ 2005 Express as both a C and a C++ program. What compiler are you using ? Does your compiler complain about the below ?
char* foo1()
{
return (char *)malloc(255);
}
int foo(void **vpSec00)
{
*vpSec00 = foo1();
return 0;
}
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
Compiled without errors/warnings with my compiler -- VC++ 2005 Express as both a C and a C++ program. What compiler are you using ? Does your compiler complain about the below ?
char* foo1()
{
return (char *)malloc(255);
}
int foo(void **vpSec00)
{
*vpSec00 = foo1();
return 0;
}
i'm using :
gcc (GCC) 3.3.3 (SuSE Linux)
it says :
warning: cast to pointer from integer of different size
for the line :
return (char *)malloc(255);
asilter
Junior Poster in Training
60 posts since Oct 2006
Reputation Points: 10
Solved Threads: 0
maybe you need to get the newest version of that compiler ??? I don't use it, so don't know.
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
i've included stdlib.h but the warning is still there. maybe i need to upgrade to gcc 4.1.2.
asilter
Junior Poster in Training
60 posts since Oct 2006
Reputation Points: 10
Solved Threads: 0
i've heard that type casting warnings are not so important.
asilter
Junior Poster in Training
60 posts since Oct 2006
Reputation Points: 10
Solved Threads: 0