comp.lang.c
[Top] [All Lists]

Re: Dynamic (as in Reflective) Programming in C?

Subject: Re: Dynamic (as in Reflective) Programming in C?
From: Eric Sosman
Date: Sat, 29 Mar 2008 09:07:10 -0400
Newsgroups: comp.lang.c


Tomás Ó hÉilidhe wrote:
On Mar 19, 3:54 pm, Eric Sosman <Eric.Sos...@xxxxxxx> wrote:
All of this is
well outside the realm of C -- C doesn't even guarantee that
you can convert between data and function pointers meaningfully.

extern void Func(void);
void (*pFunc)(void) = Func;

char unsigned buf[sizeof pFunc];
memcpy(buf,&pFunc,sizeof pFunc);

/* And then back again */

memcpy(&pFunc,buf,sizeof pFunc);

    The English language's habit of overloading tokens, when
coupled with its wavering rules of binding strength, sometimes
produce an ambiguity.  By "data and function pointers" I did
not mean "{noun:data} and {adjective:function noun:pointers},"
but "{adjective:data} and {adjective:function} {noun:pointers},"
parsing as "(data and function) pointers," not as "data and
(function pointers)."  Or, in that tricksy English, "data
pointers and function pointers."

    Sorry for the confusion.

--
Eric Sosman
esosman@xxxxxxxxxxxxxxxxxxxx

<Prev in Thread] Current Thread [Next in Thread>
Privacy Policy