• Advertisement

Archived

This topic is now archived and is closed to further replies.

Function exists?

This topic is 5754 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

In MSVC++, is there a way to test if a function exists, without using #define #ifndef and the like. I wrote out some pseudo code but I can''t convert it to c/c++.
  
void Somefunc();
if Somefunc is defined
do Main()
else
do OtherMain()
  
here I want it to goto Main(), since Somefunc is defined. any help would be helpful...

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
I don''t think so, but what are you trying to accomplish by that? Is it a part of an inheritance?

If you really gotta do something like that, the best I can say is try to set up a variable, then call the function, and have each function in the inheritance family set that variable to a certain number.

Share this post


Link to post
Share on other sites
I personally don''t really see why something like this would be necessary.

If you''re writing the code, you should know which functions exist and which don''t.

Unless you''re writing a scripting language where functions can change at runtime

Share this post


Link to post
Share on other sites
I''m trying to set-up an engine that uses some functions that the person has to create ( they are already defined in a header ). If the function isn''t created then just skip over the function. This is all in C, since I don''t like c++ that much.

Share this post


Link to post
Share on other sites
quote:
Original post by chegabon
You might want to this:
__if_exists (function_name)

What is that? Never heard of it.

The reason I advocate function pointers is that what ph4ntasyph34r is trying to implement is a callback system. It''s that or function template parameters.

[ GDNet Start Here | GDNet Search Tool | GDNet FAQ ]
[ MS RTFM [MSDN] | SGI STL Docs | Boost ]
[ Google! | Asking Smart Questions | Jargon File ]
Thanks to Kylotan for the idea!

Share this post


Link to post
Share on other sites

  • Advertisement