Skip to content

Commit 4fe34b2

Browse files
committed
Fixing warnings generated by clang 8.0 on Windows
* Deprecation removals previously specific to MSVC/Intel now also used by clang * String literals were assigned to non const pointers. These are stored in mutable arrays now * An implicit function pointer to pointer conversion is a Microsoft extension warning is suppressed by an explicit reinterpret_cast * The MSVC specific deprecation macro for jsoncpp was moved after the clang macro to avoid redefinition warnings. This is consistent with how jsoncpp fixed the issue in 36d8cfd7
1 parent 067a4f4 commit 4fe34b2

File tree

4 files changed

+32
-16
lines changed

4 files changed

+32
-16
lines changed

CompileFlags.cmake

+7-4
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,16 @@ if(WIN32 AND CMAKE_C_COMPILER_ID STREQUAL "Intel")
88
set(_INTEL_WINDOWS 1)
99
endif()
1010

11+
if(WIN32 AND CMAKE_C_COMPILER_ID STREQUAL "Clang"
12+
AND "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC")
13+
set(_CLANG_MSVC_WINDOWS 1)
14+
endif()
15+
1116
# Disable deprecation warnings for standard C functions.
1217
# really only needed for newer versions of VS, but should
1318
# not hurt other versions, and this will work into the
1419
# future
15-
if(MSVC OR _INTEL_WINDOWS)
20+
if(MSVC OR _INTEL_WINDOWS OR _CLANG_MSVC_WINDOWS)
1621
add_definitions(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE)
1722
else()
1823
endif()
@@ -21,9 +26,7 @@ if(MSVC)
2126
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stack:10000000")
2227
endif()
2328

24-
if(CMAKE_CXX_COMPILER_ID STREQUAL Clang
25-
AND "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC"
26-
AND "x${CMAKE_CXX_COMPILER_FRONTEND_VARIANT}" STREQUAL "xGNU")
29+
if(_CLANG_MSVC_WINDOWS AND "x${CMAKE_CXX_COMPILER_FRONTEND_VARIANT}" STREQUAL "xGNU")
2730
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Xlinker -stack:20000000")
2831
endif()
2932

Source/cmCallVisualStudioMacro.cxx

+8-4
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ HRESULT InstanceCallMacro(IDispatch* vsIDE, const std::string& macro,
6161

6262
if (0 != vsIDE) {
6363
DISPID dispid = (DISPID)-1;
64-
OLECHAR* name = L"ExecuteCommand";
64+
wchar_t execute_command[] = L"ExecuteCommand";
65+
OLECHAR* name = execute_command;
6566

6667
hr =
6768
vsIDE->GetIDsOfNames(IID_NULL, &name, 1, LOCALE_USER_DEFAULT, &dispid);
@@ -119,7 +120,8 @@ HRESULT InstanceCallMacro(IDispatch* vsIDE, const std::string& macro,
119120
}
120121
oss << " dwHelpContext: " << excep.dwHelpContext << std::endl;
121122
oss << " pvReserved: " << excep.pvReserved << std::endl;
122-
oss << " pfnDeferredFillIn: " << excep.pfnDeferredFillIn << std::endl;
123+
oss << " pfnDeferredFillIn: "
124+
<< reinterpret_cast<void*>(excep.pfnDeferredFillIn) << std::endl;
123125
oss << " scode: " << excep.scode << std::endl;
124126
}
125127

@@ -140,7 +142,8 @@ HRESULT GetSolutionObject(IDispatch* vsIDE, IDispatchPtr& vsSolution)
140142

141143
if (0 != vsIDE) {
142144
DISPID dispid = (DISPID)-1;
143-
OLECHAR* name = L"Solution";
145+
wchar_t solution[] = L"Solution";
146+
OLECHAR* name = solution;
144147

145148
hr =
146149
vsIDE->GetIDsOfNames(IID_NULL, &name, 1, LOCALE_USER_DEFAULT, &dispid);
@@ -183,7 +186,8 @@ HRESULT GetSolutionFullName(IDispatch* vsSolution, std::string& fullName)
183186

184187
if (0 != vsSolution) {
185188
DISPID dispid = (DISPID)-1;
186-
OLECHAR* name = L"FullName";
189+
wchar_t full_name[] = L"FullName";
190+
OLECHAR* name = full_name;
187191

188192
hr = vsSolution->GetIDsOfNames(IID_NULL, &name, 1, LOCALE_USER_DEFAULT,
189193
&dispid);

Source/cmGlobalGenerator.cxx

+13-2
Original file line numberDiff line numberDiff line change
@@ -535,11 +535,22 @@ void cmGlobalGenerator::EnableLanguage(
535535

536536
# ifdef KWSYS_WINDOWS_DEPRECATED_GetVersionEx
537537
# pragma warning(push)
538-
# pragma warning(disable : 4996)
538+
# ifdef __INTEL_COMPILER
539+
# pragma warning(disable : 1478)
540+
# elif defined __clang__
541+
# pragma clang diagnostic push
542+
# pragma clang diagnostic ignored "-Wdeprecated-declarations"
543+
# else
544+
# pragma warning(disable : 4996)
545+
# endif
539546
# endif
540547
GetVersionExW((OSVERSIONINFOW*)&osviex);
541548
# ifdef KWSYS_WINDOWS_DEPRECATED_GetVersionEx
542-
# pragma warning(pop)
549+
# ifdef __clang__
550+
# pragma clang diagnostic pop
551+
# else
552+
# pragma warning(pop)
553+
# endif
543554
# endif
544555
std::ostringstream windowsVersionString;
545556
windowsVersionString << osviex.dwMajorVersion << "."

Utilities/cmjsoncpp/include/json/config.h

+4-6
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,6 @@
7979
# pragma warning(disable : 4786)
8080
# endif // MSVC 6
8181

82-
# if _MSC_VER >= 1500 // MSVC 2008
83-
/// Indicates that the following function is deprecated.
84-
# define JSONCPP_DEPRECATED(message) __declspec(deprecated(message))
85-
# endif
86-
8782
#endif // defined(_MSC_VER)
8883

8984
// In c++11 the override keyword allows you to explicity define that a function
@@ -137,7 +132,10 @@
137132
# elif (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
138133
# define JSONCPP_DEPRECATED(message) __attribute__((__deprecated__))
139134
# endif // GNUC version
140-
#endif // __clang__ || __GNUC__
135+
#elif defined(_MSC_VER) && _MSC_VER >= 1500 // MSVC 2008
136+
/// Indicates that the following function is deprecated.
137+
# define JSONCPP_DEPRECATED(message) __declspec(deprecated(message))
138+
#endif // __clang__ || __GNUC__ || _MSC_VER
141139

142140
#undef JSONCPP_DEPRECATED // no deprecations in CMake copy
143141
#if !defined(JSONCPP_DEPRECATED)

0 commit comments

Comments
 (0)