File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ // Copyright (c) 2020 by Chrono
2+ //
3+ // g++ test04.cpp -Wall -Werror -std=c++11 -o a.out;./a.out
4+ // g++ test04.cpp -Wall -Werror -std=c++14 -o a.out;./a.out
5+ //
6+ // g++ test04.cpp -DNDEBUG -std=c++11 -o a.out;./a.out
7+ //
8+ // gcc -E -dM - < /dev/null
9+
10+ #include < iostream>
11+
12+ // [[deprecated]] // c+14 or later
13+ // [[gnu::deprecated]] // c+11 or later
14+ int old_func ()
15+ {
16+ // [[gnu::deprecated]]
17+ int value = 0 ;
18+
19+ return value;
20+ }
21+
22+ [[gnu::constructor]]
23+ void first_func ()
24+ {
25+ // can not use cout!
26+ printf (" before main()\n " );
27+ }
28+
29+ [[gnu::destructor]]
30+ void last_func ()
31+ {
32+ // can not use cout!
33+ printf (" after main()\n " );
34+ }
35+
36+ void case1 ()
37+ {
38+ using namespace std ;
39+
40+ [[gnu::unused]]
41+ int nouse;
42+
43+ cout << " case1" << endl;
44+ }
45+
46+ void case2 ()
47+ {
48+ using namespace std ;
49+
50+ cout << " case2" << endl;
51+ }
52+
53+ int main ()
54+ {
55+ // old_func();
56+
57+ case1 ();
58+ case2 ();
59+ }
You can’t perform that action at this time.
0 commit comments