Judul : C++ 2011 and __func__
link : C++ 2011 and __func__
C++ 2011 and __func__
So what happens to __func__ in different scopes? How about GCC's extension for pretty function names?#include <iostream>
using namespace std;
namespace
{
void f()
{
auto func = []()->const char *{ return(__func__); };
auto func2 = []()->const char *{ return(__PRETTY_FUNCTION__); }; //GCC extension
cout << func() << '\n'
<< func2() << '\n'
<< __func__ << '\n'
<< __PRETTY_FUNCTION__ << endl;
}
}
int main()
{
f();
cout << __func__ << '\n'
<< __PRETTY_FUNCTION__ << endl;
return(0);
}
Output:
/tmp> g++-4.5 -Wall -o test test.cpp -std=c++0x
/tmp> ./test
operator()
<unnamed>::f()::<lambda()>
f
void<unnamed>::f()
main
int main()
/tmp>
/tmp> g++-4.6 -Wall -o test test.cpp -std=c++0x
/tmp> ./test
operator()
{anonymous}::f()::<lambda()>
f
void {anonymous}::f()
main
int main()
/tmp>
Demikianlah Artikel C++ 2011 and __func__
Sekianlah artikel C++ 2011 and __func__ kali ini, mudah-mudahan bisa memberi manfaat untuk anda semua. baiklah, sampai jumpa di postingan artikel lainnya.
Anda sekarang membaca artikel C++ 2011 and __func__ dengan alamat link https://jendeladuniainternet.blogspot.com/2011/06/c-2011-and-func.html
0 Response to "C++ 2011 and __func__"
Posting Komentar