Skip to content

Commit 958af07

Browse files
committed
test03.cpp
1 parent b22cc7b commit 958af07

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

section1/test03.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
// Copyright (c) 2020 by Chrono
22
//
3+
// pre-process source:
4+
// g++ test03.cpp -E -o a.cxx
5+
//
36
// g++ test03.cpp -std=c++98 -o a.out;./a.out
47
// g++ test03.cpp -std=c++11 -o a.out;./a.out
58
// g++ test03.cpp -std=c++14 -o a.out;./a.out
@@ -9,12 +12,25 @@
912
// show all predefined macro:
1013
// gcc -E -dM - < /dev/null
1114

15+
// comment it for better pre-process output
1216
#include <iostream>
1317

18+
// macro for convienient namespace
1419
#define BEGIN_NAMESPACE(x) namespace x {
1520
#define END_NAMESPACE(x) }
1621

1722
void case1()
23+
{
24+
#
25+
#if __linux__
26+
# define HAS_LINUX 1
27+
#endif
28+
#
29+
using namespace std;
30+
cout << "linux is " << HAS_LINUX << endl;
31+
}
32+
33+
void case2()
1834
{
1935
using namespace std;
2036

@@ -73,6 +89,7 @@ END_NAMESPACE(my_own)
7389
int main()
7490
{
7591
case1();
92+
case2();
7693

7794
my_own::case3();
7895
my_own::MyClass obj;

0 commit comments

Comments
 (0)