Solved

Is there is any method to find from where a particular function is being called?????????

Posted on 2004-04-01
9
213 Views
Last Modified: 2010-04-17
Dear All,
 
    I just want to know if there is any in built function available in c++ to find from where the function is being called within a group of files.

Example :

 class1::f1()
     {
             class2::f2();
      }


   class2:f2()
    {
            //To print from where this function is being called
           // The answer should be ---------  class1::f1()
       }

0
Comment
Question by:priyashree
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 1

Expert Comment

by:spintheblack
ID: 10734520
Someone correct me if I'm wrong, but this isn't possible.  

You can do several things though

1) pass a pointer to the method if you're looking to call it
2) make a parameter where the caller must pass a string - hokey

Maybe you can tell us what you  are trying to do?
0
 
LVL 8

Expert Comment

by:plq
ID: 10735386
I think in DEBUG mode (msvc) you could probably do some calls to inspect the call stack, you might have to go into machine code to inspect it, but if its available to the debugger, its available to you.

Only someone with more than a million points would know how though. c'mon jkr.

Maybe you should post this in the C++ folder
0
 
LVL 8

Expert Comment

by:plq
ID: 10735395
why not just add a parameter of "context" to force the caller to identify himself
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 8

Expert Comment

by:plq
ID: 10735396
why not just add a parameter of "context" to force the caller to identify himself
0
 
LVL 3

Expert Comment

by:eicheled
ID: 10735709
grep and/or find on unix? Search on MS??

In principle, methods are designed to be called from many places (re-usability). Why do you need to know where it was called from??

As a humorous aside, one software shop insisted we document (INSIDE THE FILE THAT CONTAINED THE SOURCE CODE FOR THE METHOD) where it was called from!!!!!! Imagine the ridiculous logic of that decision!!!!! Every time you used a method from another file, you had to edit it's source file and add the fact that you called it.

0
 
LVL 45

Accepted Solution

by:
sunnycoder earned 50 total points
ID: 10738681
macros __FILE__ __FUNCTION__ __LINE__ give the names of current source file, current function and line number ... If you can use them it will be easy enough for you ...

It is possible to retrieve the name of the function from which current function was called but that would need reading the function call stack and getting the name from there ... As you might have guessed, it be highly implementation specific ... I do not think there is an API for this
0
 

Author Comment

by:priyashree
ID: 10738842
Hi sunnycoder,

  Thank you very much for your info.


Regards,
priyashree

0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Programming Codes 2 39
Hive vs Impla in Hadoop 1 73
Is online banking safe? 11 82
what Script langage can i run on Online Excel without having the installed version 3 54
Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question