Warnings from Calling memory addresses

Programming, for all ages and all languages.
Post Reply
User avatar
piranha
Member
Member
Posts: 1391
Joined: Thu Dec 21, 2006 7:42 pm
Location: Unknown. Momentum is pretty certain, however.
Contact:

Warnings from Calling memory addresses

Post 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
SeaOS: Adding VT-x, networking, and ARM support
dbittman on IRC, @danielbittman on twitter
https://dbittman.github.io
User avatar
Alboin
Member
Member
Posts: 1466
Joined: Thu Jan 04, 2007 3:29 pm
Location: Noricum and Pannonia

Post by Alboin »

Cast it.
C8H10N4O2 | #446691 | Trust the nodes.
User avatar
piranha
Member
Member
Posts: 1391
Joined: Thu Dec 21, 2006 7:42 pm
Location: Unknown. Momentum is pretty certain, however.
Contact:

Post by piranha »

Cast, as in

Code: Select all

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

-JL
SeaOS: Adding VT-x, networking, and ARM support
dbittman on IRC, @danielbittman on twitter
https://dbittman.github.io
User avatar
bluecode
Member
Member
Posts: 202
Joined: Wed Nov 17, 2004 12:00 am
Location: Germany
Contact:

Post by bluecode »

Code: Select all

c = (char (*)())buf;
User avatar
piranha
Member
Member
Posts: 1391
Joined: Thu Dec 21, 2006 7:42 pm
Location: Unknown. Momentum is pretty certain, however.
Contact:

Post by piranha »

Ah, of course! :oops:

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

Thanks

-JL
SeaOS: Adding VT-x, networking, and ARM support
dbittman on IRC, @danielbittman on twitter
https://dbittman.github.io
Post Reply