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.

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;
}

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);

You need to include stdlib.h. The error cryptically tells you that malloc wasn't declared and the compiler just assumes it's a function that returns int and casting from int to char* isn't friendly.

Comments
Excellent diagnosis of the problem

I included stdlib.h, and my compiler doesn't give any warning, even with all warnings on. Without stdlib h it says "incompatible implicit declaration of built-in function 'malloc'" gcc 4.1.2, debian linux.

Comments
Yes

i've included stdlib.h but the warning is still there. maybe i need to upgrade to gcc 4.1.2.

i've heard that type casting warnings are not so important.

I have the same problem with:

page_directory[0] = page_table;

where

unsigned long *page_directory = (unsigned long *) 0x9C000;
unsigned long *page_table = (unsigned long *) 0x9D000;

Note that this is to initialize paging at kernel level, so stdlib.h is NOT an option, as malloc() -- a memory allocation function -- is to be part of the memory manager this calls. how would I explicitly type-cast that?

This question has already been answered. Start a new discussion instead.