Skip to content

Commit 2650a82

Browse files
committed
cpplang.hpp
1 parent 2f253ac commit 2650a82

2 files changed

Lines changed: 62 additions & 0 deletions

File tree

section5/cpplang.hpp

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// Copyright (c) 2020 by Chrono
2+
3+
#ifndef _CPP_LANG_HPP
4+
#define _CPP_LANG_HPP
5+
6+
#include <cassert>
7+
8+
#include <iostream>
9+
#include <string>
10+
#include <vector>
11+
#include <set>
12+
#include <map>
13+
#include <unordered_set>
14+
#include <unordered_map>
15+
#include <algorithm>
16+
17+
//never 'using namespace std;' in c++ header
18+
19+
// must be C++11 or later
20+
#if __cplusplus < 201103
21+
# error "C++ is too old"
22+
#endif // __cplusplus >= 201402
23+
24+
static_assert(
25+
__GNUC__ >= 4, "GCC is too old");
26+
27+
#if __cplusplus >= 201402
28+
# define CPP_DEPRECATED [[deprecated]]
29+
#else
30+
# define CPP_DEPRECATED [[gnu::deprecated]]
31+
#endif // __cplusplus >= 201402
32+
33+
// macro for convienient namespace
34+
#define BEGIN_NAMESPACE(x) namespace x {
35+
#define END_NAMESPACE(x) }
36+
37+
#endif //_CPP_LANG_HPP
38+

section5/srv.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Copyright (c) 2020 by Chrono
2+
//
3+
// g++ srv.cpp -std=c++11 -o a.out;./a.out
4+
// g++ srv.cpp -std=c++14 -o a.out;./a.out
5+
// g++ srv.cpp -std=c++14 -I../common -o a.out;./a.out
6+
7+
//#include <iostream>
8+
9+
#include "cpplang.hpp"
10+
11+
int main()
12+
{
13+
using namespace std;
14+
15+
cout << "c++ version = " << __cplusplus << endl;
16+
17+
cout << "gcc version = " << __VERSION__ << endl;
18+
19+
cout << "gcc major = " << __GNUC__ << endl;
20+
cout << "gcc minor = " << __GNUC_MINOR__ << endl;
21+
cout << "gcc patch = " << __GNUC_PATCHLEVEL__ << endl;
22+
23+
cout << "libstdc++ = " << __GLIBCXX__ << endl;
24+
}

0 commit comments

Comments
 (0)