Skip to content

Commit 25fe6d7

Browse files
authored
Merge pull request simdjson#859 from simdjson/jkeiser/vsquickstart
Eliminate Intellisense errors and warnings in new VS project
2 parents 73e27bd + afb3699 commit 25fe6d7

14 files changed

+960
-911
lines changed

benchmark/benchmarker.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#define __BENCHMARKER_H
33

44
#include "event_counter.h"
5+
#include "simdjson.h" // For SIMDJSON_DISABLE_DEPRECATED_WARNINGS
56

67
#include <cassert>
78
#include <cctype>
@@ -435,7 +436,11 @@ struct benchmarker {
435436
void print(bool tabbed_output) const {
436437
if (tabbed_output) {
437438
char* filename_copy = (char*)malloc(strlen(filename)+1);
439+
SIMDJSON_PUSH_DISABLE_WARNINGS
440+
SIMDJSON_DISABLE_DEPRECATED_WARNING // Validated CRT_SECURE safe here
438441
strcpy(filename_copy, filename);
442+
SIMDJSON_POP_DISABLE_WARNINGS
443+
439444
#if defined(__linux__)
440445
char* base = ::basename(filename_copy);
441446
#else

include/simdjson.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@
1111
#include "simdjson/common_defs.h"
1212

1313
SIMDJSON_PUSH_DISABLE_WARNINGS
14-
#if defined(_MSC_VER) && defined(__clang__)
15-
SIMDJSON_DISABLE_GCC_WARNING(-Wmicrosoft-include)
16-
#endif
14+
SIMDJSON_DISABLE_UNDESIRED_WARNINGS
1715

1816
// Public API
1917
#include "simdjson/simdjson_version.h"

include/simdjson/common_defs.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,12 @@ constexpr size_t DEFAULT_MAX_DEPTH = 1024;
7777
#define unlikely(x) x
7878
#endif
7979

80+
#include <CppCoreCheck\Warnings.h>
8081
#define SIMDJSON_PUSH_DISABLE_WARNINGS __pragma(warning( push ))
8182
#define SIMDJSON_PUSH_DISABLE_ALL_WARNINGS __pragma(warning( push, 0 ))
8283
#define SIMDJSON_DISABLE_VS_WARNING(WARNING_NUMBER) __pragma(warning( disable : WARNING_NUMBER ))
84+
// Get rid of Intellisense-only warnings (Code Analysis)
85+
#define SIMDJSON_DISABLE_UNDESIRED_WARNINGS SIMDJSON_DISABLE_VS_WARNING(ALL_CPPCORECHECK_WARNINGS)
8386
#define SIMDJSON_DISABLE_DEPRECATED_WARNING SIMDJSON_DISABLE_VS_WARNING(4996)
8487
#define SIMDJSON_POP_DISABLE_WARNINGS __pragma(warning( pop ))
8588

@@ -113,6 +116,11 @@ constexpr size_t DEFAULT_MAX_DEPTH = 1024;
113116
SIMDJSON_DISABLE_GCC_WARNING(-Wunused-variable)
114117
#define SIMDJSON_PRAGMA(P) _Pragma(#P)
115118
#define SIMDJSON_DISABLE_GCC_WARNING(WARNING) SIMDJSON_PRAGMA(GCC diagnostic ignored #WARNING)
119+
#if defined(SIMDJSON_CLANG_VISUAL_STUDIO)
120+
#define SIMDJSON_DISABLE_UNDESIRED_WARNINGS SIMDJSON_DISABLE_GCC_WARNING(-Wmicrosoft-include)
121+
#else
122+
#define SIMDJSON_DISABLE_UNDESIRED_WARNINGS
123+
#endif
116124
#define SIMDJSON_DISABLE_DEPRECATED_WARNING SIMDJSON_DISABLE_GCC_WARNING(-Wdeprecated-declarations)
117125
#define SIMDJSON_POP_DISABLE_WARNINGS _Pragma("GCC diagnostic pop")
118126

include/simdjson/inline/document.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,11 @@ inline bool parser::dump_raw_tape(std::ostream &os) const noexcept {
339339

340340
inline simdjson_result<size_t> parser::read_file(const std::string &path) noexcept {
341341
// Open the file
342+
SIMDJSON_PUSH_DISABLE_WARNINGS
343+
SIMDJSON_DISABLE_DEPRECATED_WARNING // Disable CRT_SECURE warning on MSVC: manually verified this is safe
342344
std::FILE *fp = std::fopen(path.c_str(), "rb");
345+
SIMDJSON_POP_DISABLE_WARNINGS
346+
343347
if (fp == nullptr) {
344348
return IO_ERROR;
345349
}

include/simdjson/inline/padded_string.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,11 @@ inline padded_string::operator std::string_view() const { return std::string_vie
102102

103103
inline simdjson_result<padded_string> padded_string::load(const std::string &filename) noexcept {
104104
// Open the file
105+
SIMDJSON_PUSH_DISABLE_WARNINGS
106+
SIMDJSON_DISABLE_DEPRECATED_WARNING // Disable CRT_SECURE warning on MSVC: manually verified this is safe
105107
std::FILE *fp = std::fopen(filename.c_str(), "rb");
108+
SIMDJSON_POP_DISABLE_WARNINGS
109+
106110
if (fp == nullptr) {
107111
return IO_ERROR;
108112
}

simdjson-flags.cmake

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ add_library(simdjson-internal-flags INTERFACE)
3939
target_link_libraries(simdjson-internal-flags INTERFACE simdjson-flags)
4040

4141
if(MSVC)
42-
target_compile_options(simdjson-internal-flags INTERFACE /nologo /D_CRT_SECURE_NO_WARNINGS)
4342
target_compile_options(simdjson-internal-flags INTERFACE /WX /W3 /sdl)
4443
else()
4544
target_compile_options(simdjson-internal-flags INTERFACE -fPIC)

0 commit comments

Comments
 (0)