Page 1 of 1

djgpp Integer made from pointer without a cast

Posted: Mon Mar 24, 2003 12:00 am
by OSNewbie
lets say i have a function putDec(int number) which prints the number in decimal. this works great. now i have a function enable_ints() or any function really, and i call putDec(enable_ints) because i want to know the address of the function. this compiles with a warning but appears to print the correct address.

the warning is what i am wondering about: it says (upon linking with LD): "Integer made from pointer without a cast" or something like that. is there another variable type besides int to use with pointers? i am new to C and djgpp and do not know all the variable types...

thanks

OSNewbie

RE:djgpp Integer made from pointer without a cast

Posted: Mon Mar 24, 2003 12:00 am
by Tim Robinson
Pointers are a separate type in C from integers. Pointers generally have a * in their name. For your putDec() function it's safe to type-cast the parameter (so you do putDec((int) enable_ints) ) but you should read up on pointers anyway, as they are vital.

RE:djgpp Integer made from pointer without a cast

Posted: Mon Mar 24, 2003 12:00 am
by phil
a pointer to a function is what you use.  lets say the prototype for enable_ints() is:
void enable_ints(void);

then a pointer to that type of function (no parameters, no return) would be:
void (*pFunction)(void) = enable_ints;