Page 1 of 1

Warnings from Calling memory addresses

Posted: Thu Apr 24, 2008 8:34 pm
by piranha
When I have loaded a binary file into a buffer, say, named

Code: Select all

char buf[1024]
and I want to call it, I define a

Code: Select all

char (*c)();
variable, and set the equal:

Code: Select all

c = buf;
and go

Code: Select all

c();
When I do so, I get a warning message:

Code: Select all

warning: assignment from incompatible pointer type
Is there a way in the coding to get rid of that?

-JL

Posted: Thu Apr 24, 2008 8:57 pm
by Alboin
Cast it.

Posted: Thu Apr 24, 2008 10:19 pm
by piranha
Cast, as in

Code: Select all

c = (char *)buf;
? This doesn't change the warning at all.

-JL

Posted: Thu Apr 24, 2008 10:24 pm
by bluecode

Code: Select all

c = (char (*)())buf;

Posted: Thu Apr 24, 2008 10:51 pm
by piranha
Ah, of course! :oops:

I should have realized that... ](*,)

Thanks

-JL