advertisement
Login | Register   
  Include Code  Search Tips
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Which other bits of function-related information do you need to access often? How would you design a built-in facility for obtaining this information? Let us know in the DevX C++ Forum.
Partners & Affiliates
advertisement
advertisement
advertisement
advertisement
Average Rating: 3.9/5 | Rate this item | 16 users have rated this item.
 

Retrieve a Function's Name Programmatically

Embedding a hard-coded string inside a function's body in order to retrieve that function's name can be tedious and bug-prone. Learn how to use a new C99 facility to obtain the function's name at runtime. 


advertisement
bject reflection libraries, debugging tools, and code analyzers often need to access functions' names at runtime. Until not long ago, the only portable way to accomplish this was to manually embed a hard-coded string with the function's name inside the function's body. Needless to say, this technique is very tedious and bug-prone. This article demonstrates how to use a new C99 facility to obtain a function's name at runtime.


How can you access the name of a currently executing function programmatically?


Use the __FUNCTION__ facility and its related macros.

  Next Page: Presenting the Problem
Page 1: IntroductionPage 3: Signatures and Decorated Names
Page 2: Presenting the Problem 
Please rate this item (5=best)
 1  2  3  4  5
advertisement