Use __PRETTY_FUNCTION__ and __func__.
David Blume

David Blume commited on 2015-11-08 01:17:45
Showing 3 changed files, with 4 additions and 4 deletions.

... ...
@@ -4,11 +4,11 @@
4 4
 using namespace std;
5 5
 
6 6
 int my_lib_fn() {
7
-    cout << "The function my_lib_fn() was called." << endl;
7
+    cout << "The function " << __func__ << " was called." << endl;
8 8
     return 0;
9 9
 }
10 10
 
11 11
 int my_lib_fn(int x) {
12
-    cout << "The function my_lib_fn with parameter " << x << " was called." << endl;
12
+    cout << "The function " << __PRETTY_FUNCTION__ << " with parameter " << x << " was called." << endl;
13 13
     return x+1;
14 14
 }
... ...
@@ -12,7 +12,7 @@ int read( std::string const &directory, const std::vector<unsigned char> &secret
12 12
 }
13 13
 
14 14
 int main_helper_fn() {
15
-    cout << "The function main_helper_fn was called." << endl;
15
+    cout << "The function " << __PRETTY_FUNCTION__ << " was called." << endl;
16 16
 	string                my_string("Hello");
17 17
 	vector<unsigned char> secret;
18 18
 	cout << "The length of hello is " << read(my_string, secret) << endl;
... ...
@@ -8,7 +8,7 @@ using namespace std;
8 8
 namespace UI {
9 9
 
10 10
 int widget_cb() {
11
-    cout << "The function main_helper_fn was called." << endl;
11
+    cout << "The function " << __PRETTY_FUNCTION__ << " was called." << endl;
12 12
     return 0;
13 13
 }
14 14
 
15 15