Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > function name from function pointer

Reply
Thread Tools

function name from function pointer

 
 
Jorgen Grahn
Guest
Posts: n/a
 
      11-06-2010
On Thu, 2010-11-04, Alessandro Basili wrote:
> On 11/3/2010 10:58 PM, Jorgen Grahn wrote:

....
>> What are you trying to accomplish? Perhaps there is a solution to
>> your problem which doesn't involve knowing the names of your
>> functions.
>>

>
> I have implemented a state machine, using pointers to function for
> states. The dispatcher provides events to the states and a change in the
> state is simply accomplished changing the "state" pointer to yet another
> function (the layout of the program can be found here:
> http://www.netrino.com/Embedded-Syst...Driven-Systems,
> in listing 1,2 and 3).
>
> I found the approach quite nice and easily scalable to more complex
> problems, without having the need to maintain any table (events, states)
> or the burden of so many switch/case scattered around.
>
> My problem though is that in this approach is not quite easy to print in
> which state I am, since the state is represented only by the function
> pointer. That is why I thought that having the possibility to get the
> name of the function from its pointer would have helped me out.


Ah, good. Now I see what you want and why.

I guess I'd go: "Damn, it's hard to print what state I'm in. Oh well
-- maybe I don't really need to print that after all." And then I'd
wait until I had an urgent need to print that info.

If it's just for debugging (which IMHO it should be) I'd probably be
satisfied with seeing the function pointers in hex, knowing I can
translate them to names if I want to (using nm(1) on Unix).

/Jorgen

--
// Jorgen Grahn <grahn@ Oo o. . .
\X/ snipabacken.se> O o .
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
pointer to an array vs pointer to pointer subramanian100in@yahoo.com, India C Programming 5 09-23-2011 10:28 AM
Pointer to pointer or reference to pointer A C++ 7 07-05-2011 07:49 PM
Pointer to pointer Vs References to Pointer bansalvikrant@gmail.com C++ 4 07-02-2009 10:20 AM
passing the address of a pointer to a func that doesnt recieve a pointer-to-a-pointer jimjim C Programming 16 03-27-2006 11:03 PM
Pointer-to-pointer-to-pointer question masood.iqbal@lycos.com C Programming 10 02-04-2005 02:57 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57