Skip to content

Commit 5728757

Browse files
committed
fix compile on old gcc.
1 parent bcd0df1 commit 5728757

File tree

4 files changed

+52
-2
lines changed

4 files changed

+52
-2
lines changed

cpp/.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,3 @@ build/
55
.settings/
66
.vscode/
77
cmake-build-debug/
8-
cmake*/

cpp/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ Modify the Toolchain File `cmake/ToolChain.cmake`, define the following variable
7575
In the `cpp/` directory, run the following commands to create the build directory and start the compilation:
7676
```
7777
mkdir build && cd build
78-
cmake .. -DToolChian=ON
78+
cmake .. -DToolChain=ON
7979
make
8080
```
8181

cpp/cmake/ToolChain.cmake

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#[[
2+
Licensed to the Apache Software Foundation (ASF) under one
3+
or more contributor license agreements. See the NOTICE file
4+
distributed with this work for additional information
5+
regarding copyright ownership. The ASF licenses this file
6+
to you under the Apache License, Version 2.0 (the
7+
"License"); you may not use this file except in compliance
8+
with the License. You may obtain a copy of the License at
9+
10+
https://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing,
13+
software distributed under the License is distributed on an
14+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
KIND, either express or implied. See the License for the
16+
specific language governing permissions and limitations
17+
under the License.
18+
]]
19+
20+
set(CMAKE_SYSTEM_NAME Linux)
21+
set(CMAKE_SYSTEM_PROCESSOR aarch64)
22+
23+
## Modify
24+
set(CMAKE_C_COMPILER /home/tsfile/dev/gcc-linaro-5.5.0-2017.10-x86_64_arm-linux-gnueabi/bin/arm-linux-gnueabi-gcc CACHE STRING "Path to the C compiler" FORCE)
25+
set(CMAKE_CXX_COMPILER /home/colin/dev/gcc-linaro-5.5.0-2017.10-x86_64_arm-linux-gnueabi/bin/arm-linux-gnueabi-g++ CACHE STRING "Path to the C++ compiler" FORCE)
26+
message(STATUS "using cxx compiler ${CMAKE_CXX_COMPILER}")
27+
message(STATUS "using c compiler ${CMAKE_C_COMPILER}")
28+
## Modify
29+
set(CMAKE_FIND_ROOT_PATH /home/tsfile/dev/gcc-linaro-5.5.0-2017.10-x86_64_arm-linux-gnueabi)
30+
31+
32+
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
33+
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH)
34+
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH)
35+
36+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

cpp/src/common/db_common.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@
2020
#ifndef COMMON_DB_COMMON_H
2121
#define COMMON_DB_COMMON_H
2222

23+
#include <functional>
2324
#include <iostream>
25+
#include <type_traits>
2426
#include <unordered_set>
2527

2628
#include "common/allocator/my_string.h"
@@ -94,7 +96,20 @@ enum CompressionType : uint8_t {
9496
extern const char* s_data_type_names[8];
9597
extern const char* s_encoding_names[12];
9698
extern const char* s_compression_names[8];
99+
}
97100

101+
#if defined(__GLIBCXX__) && (__GNUC__ < 7)
102+
namespace std {
103+
template <>
104+
struct hash<common::TSDataType> {
105+
size_t operator()(common::TSDataType v) const noexcept {
106+
return static_cast<size_t>(static_cast<uint8_t>(v));
107+
}
108+
};
109+
} // namespace std
110+
#endif
111+
112+
namespace common {
98113
FORCE_INLINE const char* get_data_type_name(TSDataType type) {
99114
ASSERT(type >= BOOLEAN && type <= STRING);
100115
return s_data_type_names[type];

0 commit comments

Comments
 (0)