how How can I check a function was called by another function?



I am currently trying to make sure that a member function of one class is only called by a member function of another class.

The architecture is imposed and cannot be changed, the port means that some logic has to be done in before calling therefore calls to simplify things and make sure the order is respected.

I found this answer to my question. Only, the problem is that I am using classes, and the two classes have the same member function name and so the #define tries to replace all the occurrences which have different prototypes.





Off the top of my head, options would be:

  • Make private and make b add a or as a friend
  • Turn into a class and put the body into a a private constructor with a or as a friend
  • grep the source code for, make sure the only call is in, and add a comment at the declaration saying “if you call this function you will be fired”
  • Change to take at least one of the values it needs as a parameter (even if it ignores it and uses the value from somewhere else)


[], [], []

Facebook Comments

Post a comment