|
-
April 9th, 2003, 03:03 AM
#1
does the function exist?
Hello!
I want to use a Pointer-to-Function to switch between different functions inside our own proprietary operating system.
What I want to archieve is, that without any change my code, my code is able to check whether a function with a known name exists or not.
Do you have any idea how to manage this in plain C?
Thanks!
Example:
I think about something like:
a()
{
//do something
}
main()
{
..
void (*PtF) (void);
if (exist(function a))
{
PtF = a;
PtF();
}
..
}
-
April 9th, 2003, 03:07 AM
#2
Set up a linked list of structures containing a string and a function pointer. Register every function in the list. To find out whether a function exist, traverse the list and check the names.
-
April 9th, 2003, 05:16 AM
#3
Thanks, Gabriel!
I think I will have to use this solution, although it has a disadvantage:
Doing this requires, that the application programmer has to think of the list. He has to program things that he does not need in this moment for his project. So the acceptance of my colleagues will not be too good.
I do not think that there is any better solution.
Again: Thanks!
Marc
-
April 9th, 2003, 07:43 AM
#4
Maybe not what you want (and not very portable) but if your
developing on a Windows platform and your functions are
contianed in a DLL you can use GetProcAddress() to check
for their existence.
regards, willchop
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|