Skip to content

Commit fd418f5

Browse files
committed
Fix c++11 warnings on clang
- namespace x::y is C++17 - static_assert requires message in C++11
1 parent 09cf18a commit fd418f5

54 files changed

Lines changed: 318 additions & 204 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.appveyor.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,11 @@ build_script:
2020
- mkdir build
2121
- cd build
2222
- cmake -DSIMDJSON_BUILD_STATIC=%SIMDJSON_BUILD_STATIC% -DSIMDJSON_ENABLE_THREADS=%SIMDJSON_ENABLE_THREADS% -DCMAKE_BUILD_TYPE=%Configuration% -DCMAKE_GENERATOR_PLATFORM=x64 -DSIMDJSON_GOOGLE_BENCHMARKS=OFF ..
23-
- cmake --verbose --build . --config %Configuration%
23+
- cmake -LH ..
24+
- cmake --build . --config %Configuration% --verbose
2425

2526
test_script:
26-
- ctest --verbose --output-on-failure -C %Configuration%
27+
- ctest --output-on-failure -C %Configuration% --verbose
2728

2829
matrix:
2930
fast_finish: true

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ objs
8787
/examples/quickstart/twitter.json
8888
/fuzz/fuzz_dump
8989
/fuzz/fuzz_dump_raw_tape
90+
/fuzz/fuzz_minify
9091
/fuzz/fuzz_parser
9192
/fuzz/fuzz_print_json
9293
/get_corpus_benchmark

CMakeLists.txt

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ set(SIMDJSON_LIB_SOVERSION "1" CACHE STRING "simdjson library soversion")
2020

2121
if(MSVC)
2222
option(SIMDJSON_BUILD_STATIC "Build a static library" ON) # turning it on disables the production of a dynamic library
23-
set(SIMDJSON_COMPETITION CACHE STRING "Compile competitive benchmarks" OFF)
24-
else()
23+
option(SIMDJSON_COMPETITION "Compile competitive benchmarks" OFF)
24+
else()
2525
option(SIMDJSON_BUILD_STATIC "Build a static library" OFF) # turning it on disables the production of a dynamic library
2626
option(SIMDJSON_COMPETITION "Compile competitive benchmarks" ON)
2727
endif()
@@ -104,6 +104,22 @@ if(${CMAKE_C_COMPILER_ID} MATCHES "Intel") # icc / icpc
104104
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -static-intel")
105105
endif()
106106

107+
# Workaround for https://gitlab.kitware.com/cmake/cmake/issues/15415#note_633938:
108+
function(export_private_library NAME)
109+
install(TARGETS ${NAME}
110+
EXPORT ${NAME}-config
111+
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
112+
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
113+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
114+
)
115+
install(EXPORT ${NAME}-config
116+
FILE ${NAME}-config.cmake
117+
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/simdjson-private
118+
)
119+
endfunction()
120+
121+
export_private_library(simdjson-flags)
122+
107123
#
108124
# Create the top level simdjson library (must be done at this level to use both src/ and include/
109125
# directories)

HACKING.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,10 @@ simdjson's source structure, from the top level, looks like this:
2626
compiled multiple times, from whichever architectures use them. They assume they are already
2727
enclosed in a namespace, e.g.:
2828
```c++
29-
namespace simdjson::haswell {
30-
#include "generic/stage1_find_marks.h"
29+
namespace simdjson {
30+
namespace haswell {
31+
#include "generic/stage1_find_marks.h"
32+
}
3133
}
3234
```
3335

examples/quickstart/CMakeLists.txt

Lines changed: 45 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -2,51 +2,56 @@
22
# Quickstart compile tests don't require any flags
33
#
44

5-
# TODO run amalgamate first!
6-
7-
function(add_quickstart_test TEST_NAME SOURCE_FILE)
8-
# Second argument is C++ standard name
9-
if (${ARGV2})
5+
# TODO haven't quite decided the right way to run quickstart on Windows. Needs README update.
6+
if (NOT MSVC)
7+
# TODO run amalgamate first!
8+
function(add_quickstart_test TEST_NAME SOURCE_FILE)
9+
# Second argument is C++ standard name
1010
if (MSVC)
11-
set(QUICKSTART_FLAGS /std:${ARGV2})
12-
else()
13-
set(QUICKSTART_FLAGS -Werror -std=${ARGV2})
14-
endif()
15-
else()
16-
if(MSVC)
17-
set(QUICKSTART_FLAGS "")
11+
if (${ARGV2})
12+
set(QUICKSTART_FLAGS /std:${ARGV2})
13+
else()
14+
set(QUICKSTART_FLAGS /WX)
15+
endif()
16+
set(QUICKSTART_INCLUDE /I${PROJECT_SOURCE_DIR}/include /I${PROJECT_SOURCE_DIR}/src ${PROJECT_SOURCE_DIR}/src/simdjson.cpp)
1817
else()
19-
set(QUICKSTART_FLAGS -Werror)
18+
if (${ARGV2})
19+
set(QUICKSTART_FLAGS -Werror -std=${ARGV2})
20+
else()
21+
set(QUICKSTART_FLAGS -Werror)
22+
endif()
23+
set(QUICKSTART_INCLUDE -I${PROJECT_SOURCE_DIR}/include -I${PROJECT_SOURCE_DIR}/src ${PROJECT_SOURCE_DIR}/src/simdjson.cpp)
2024
endif()
21-
endif()
2225

23-
# Third argument tells whether to compile with -fno-exceptions
24-
if (${ARGV3})
25-
if (NOT MSVC)
26-
set(QUICKSTART_FLAGS "${QUICKSTART_FLAGS} -fno-exceptions")
26+
# Third argument tells whether to compile with -fno-exceptions
27+
if (${ARGV3})
28+
if (NOT MSVC)
29+
set(QUICKSTART_FLAGS ${QUICKSTART_FLAGS} -fno-exceptions)
30+
endif()
2731
endif()
28-
endif()
2932

30-
add_test(
31-
NAME ${TEST_NAME}
32-
COMMAND ${CMAKE_CXX_COMPILER} ${QUICKSTART_FLAGS} -I${PROJECT_SOURCE_DIR}/include -I${PROJECT_SOURCE_DIR}/src ${PROJECT_SOURCE_DIR}/src/simdjson.cpp ${SOURCE_FILE}
33-
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/examples/quickstart
34-
)
35-
set_property(
36-
TEST ${TEST_NAME}
37-
APPEND PROPERTY DEPENDS simdjson-source ${PROJECT_SOURCE_DIR}/examples/quickstart/quickstart.cpp
38-
)
39-
endfunction(add_quickstart_test)
33+
message(STATUS ${TEST_NAME})
34+
add_test(
35+
NAME ${TEST_NAME}
36+
COMMAND ${CMAKE_CXX_COMPILER} ${QUICKSTART_FLAGS} -I${PROJECT_SOURCE_DIR}/include -I${PROJECT_SOURCE_DIR}/src ${PROJECT_SOURCE_DIR}/src/simdjson.cpp ${SOURCE_FILE}
37+
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/examples/quickstart
38+
)
39+
set_property(
40+
TEST ${TEST_NAME}
41+
APPEND PROPERTY DEPENDS simdjson-source ${PROJECT_SOURCE_DIR}/examples/quickstart/${SOURCE_FILE}
42+
)
43+
endfunction(add_quickstart_test)
4044

41-
if (SIMDJSON_EXCEPTIONS)
42-
add_quickstart_test(quickstart quickstart.cpp)
43-
add_quickstart_test(quickstart11 quickstart.cpp c++11)
44-
add_quickstart_test(quickstart14 quickstart.cpp c++14)
45-
set_property( TEST quickstart quickstart11 APPEND PROPERTY LABELS quicktests )
46-
set_property( TEST quickstart14 APPEND PROPERTY LABELS slowtests )
47-
endif()
45+
if (SIMDJSON_EXCEPTIONS)
46+
add_quickstart_test(quickstart quickstart.cpp)
47+
add_quickstart_test(quickstart11 quickstart.cpp c++11)
48+
add_quickstart_test(quickstart14 quickstart.cpp c++14)
49+
set_property( TEST quickstart quickstart11 APPEND PROPERTY LABELS quicktests )
50+
set_property( TEST quickstart14 APPEND PROPERTY LABELS slowtests )
51+
endif()
4852

49-
add_quickstart_test(quickstart_noexceptions quickstart_noexceptions.cpp "" true)
50-
add_quickstart_test(quickstart_noexceptions11 quickstart_noexceptions.cpp c++11 true)
51-
set_property( TEST quickstart_noxceptions APPEND PROPERTY LABELS quicktests )
52-
set_property( TEST quickstart_noexceptions11 APPEND PROPERTY LABELS slowtests )
53+
add_quickstart_test(quickstart_noexceptions quickstart_noexceptions.cpp "" true)
54+
add_quickstart_test(quickstart_noexceptions11 quickstart_noexceptions.cpp c++11 true)
55+
set_property( TEST quickstart_noexceptions APPEND PROPERTY LABELS quicktests )
56+
set_property( TEST quickstart_noexceptions11 APPEND PROPERTY LABELS slowtests )
57+
endif()

include/CMakeLists.txt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@
66
#
77
add_library(simdjson-headers INTERFACE)
88
target_compile_features(simdjson-headers INTERFACE cxx_std_11) # headers require at least C++11
9-
target_include_directories(simdjson-headers INTERFACE
10-
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
11-
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
12-
)
9+
target_include_directories(simdjson-headers INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
1310

1411
install(TARGETS simdjson-headers
1512
EXPORT simdjson-headers-config

include/simdjson.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@
1717
#include "simdjson/document.h"
1818
#include "simdjson/document_stream.h"
1919

20-
// Deprecated API
20+
// // Deprecated API
2121
#include "simdjson/jsonparser.h"
2222
#include "simdjson/parsedjson.h"
2323
#include "simdjson/parsedjson_iterator.h"
2424

25-
// Inline functions
25+
// // Inline functions
2626
#include "simdjson/inline/document.h"
2727
#include "simdjson/inline/document_stream.h"
2828
#include "simdjson/inline/error.h"

include/simdjson/document.h

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
#include "simdjson/simdjson.h"
1111
#include "simdjson/padded_string.h"
1212

13-
namespace simdjson::dom {
13+
namespace simdjson {
14+
namespace dom {
1415

1516
class parser;
1617
class element;
@@ -23,9 +24,7 @@ class document_stream;
2324
/** The default batch size for parser.parse_many() and parser.load_many() */
2425
static constexpr size_t DEFAULT_BATCH_SIZE = 1000000;
2526

26-
} // namespace simdjson::dom
27-
28-
namespace simdjson {
27+
} // namespace dom
2928

3029
template<> struct simdjson_result<dom::element>;
3130
template<> struct simdjson_result<dom::array>;
@@ -34,9 +33,7 @@ template<> struct simdjson_result<dom::object>;
3433
template<typename T>
3534
class minify;
3635

37-
} // namespace simdjson
38-
39-
namespace simdjson::internal {
36+
namespace internal {
4037

4138
using namespace simdjson::dom;
4239

@@ -90,9 +87,9 @@ class tape_ref {
9087
size_t json_index;
9188
};
9289

93-
} // namespace simdjson::internal
90+
} // namespace internal
9491

95-
namespace simdjson::dom {
92+
namespace dom {
9693

9794
/**
9895
* The actual concrete type of a JSON element
@@ -1087,7 +1084,8 @@ class parser {
10871084
friend class document_stream;
10881085
}; // class parser
10891086

1090-
} // namespace simdjson::dom
1087+
} // namespace dom
1088+
} // namespace simdjson
10911089

10921090
namespace simdjson {
10931091

include/simdjson/document_stream.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
#include <thread>
55
#include "simdjson/document.h"
66

7-
namespace simdjson::dom {
7+
namespace simdjson {
8+
namespace dom {
89

910
/**
1011
* A forward-only stream of documents.
@@ -140,6 +141,7 @@ class document_stream {
140141
friend class dom::parser;
141142
}; // class document_stream
142143

143-
} // end of namespace simdjson::dom
144+
} // namespace dom
145+
} // namespace simdjson
144146

145147
#endif // SIMDJSON_DOCUMENT_STREAM_H

include/simdjson/implementation.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ class atomic_ptr {
218218
std::atomic<T*> ptr;
219219
};
220220

221-
} // namespace [simdjson::]internal
221+
} // namespace internal
222222

223223
/**
224224
* The list of available implementations compiled into simdjson.

0 commit comments

Comments
 (0)