Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <vector>
- // using std::vector
- #include <cstdio>
- // using std::printf
- std::vector<const char*> calltrace;
- #define trace(x) calltrace.push_back(#x); x; calltrace.pop_back();
- namespace {
- void foo(int z)
- {
- std::printf("Calltrace contains:\n");
- for(std::vector<const char*>::iterator i = calltrace.begin(),
- end = calltrace.end(); i != end; ++i)
- std::printf("\t%s\n", *i);
- std::printf("\n");
- }
- void bar()
- {
- int x = 0, y = 1;
- trace(int z = x + y)
- trace(foo(z))
- }
- }
- int main()
- {
- trace(bar())
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement