Skip to content

Commit d42381f

Browse files
committed
test04.cpp
1 parent dd16150 commit d42381f

1 file changed

Lines changed: 59 additions & 0 deletions

File tree

section1/test04.cpp

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
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+
}

0 commit comments

Comments
 (0)