Is there a way to extract the function name and parameters (both values and types) of a C++ function?
-
What I would like to do is, for a function defined as: LONG Try_Function (int ID, DWORD dID, LPVOID lpParams) { //Do or call something here that returns function name (Try_Function), //all parameters, their values as passed in, and if possible, their types } Edit: I know that VS supports the __FUNCTION__ macro which will give me the function name. Any tips on how to extract the parameters, with types?
-
Answer:
Read about lex
Nagasuri Bala Venkateswarlu at Quora Visit the source
Other answers
You can use the __func__ magic word to get the name of the function (some compilers may support different variants, like __PRETTY_FUNCTION__ in g++). I can't think of a way to dump all the arguments without specifying them explicitly. If you're willing to change the function's signature, you may be able to do something clever using variadic templates or variadic arguments.
Jelle Zijlstra
There is no standard way, although for compatibility's sake __FUNCTION__ is supported by both VS and gcc. But please keep in mind that it's a compiler extension.
Dorin LazÄr
Related Q & A:
- How to access a nested function from another nested function in javascript?Best solution by devarticles.com
- Is there a way to change your name on Facebook?Best solution by Yahoo! Answers
- Is there an easy way to extract audio from a DVD?Best solution by dvdae.com
- Is their a way that i can find out someones real name with Just their AOL screen name?Best solution by Yahoo! Answers
- Is there a way to change a name on Messenger?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.