Skip to content

Commit be10065

Browse files
committed
[ZH] Upgrade to c++17 (#426)
1 parent 05d3904 commit be10065

File tree

7 files changed

+31
-7
lines changed

7 files changed

+31
-7
lines changed

CMakeLists.txt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,21 @@ include(cmake/gamespy.cmake)
7474
include(cmake/lzhl.cmake)
7575
include(cmake/zlib.cmake)
7676
add_subdirectory(Dependencies/Benchmark)
77-
add_subdirectory(Dependencies/SafeDisc)
7877
add_subdirectory(Dependencies/MaxSDK)
78+
add_subdirectory(Dependencies/SafeDisc)
79+
add_subdirectory(Dependencies/Utility)
7980

8081
if (NOT IS_VS6_BUILD)
82+
# Set C++ standard
83+
set(CMAKE_CXX_STANDARD 17)
84+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
85+
set(CMAKE_CXX_EXTENSIONS OFF) # Ensures only ISO features are used
86+
8187
if (MSVC)
8288
# Multithreaded build.
8389
add_compile_options(/MP)
90+
# Enforce strict __cplusplus version
91+
add_compile_options(/Zc:__cplusplus)
8492
endif()
8593
endif()
8694

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
add_library(gz_utility INTERFACE)
2+
3+
target_include_directories(gz_utility INTERFACE ".")
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// TheSuperHackers
2+
// This file contains macros to help upgrade the code for newer cpp standards.
3+
4+
#pragma once
5+
6+
#if __cplusplus >= 201703L
7+
#define NOEXCEPT_17 noexcept
8+
#else
9+
#define NOEXCEPT_17
10+
#endif

GeneralsMD/Code/GameEngine/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1165,6 +1165,7 @@ target_link_libraries(z_gameengine PUBLIC
11651165
d3d8lib
11661166
gamespy::gamespy
11671167
gz_config
1168+
gz_utility
11681169
stlport
11691170
z_browserdispatch
11701171
z_compression

GeneralsMD/Code/GameEngine/Include/GameNetwork/WOLBrowser/WebBrowser.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
#include <Common/GameMemory.h>
5252
#include "EABrowserDispatch/BrowserDispatch.h"
5353
#include "FEBDispatch.h"
54+
#include <Utility/CppMacros.h>
5455

5556
class GameWindow;
5657

@@ -112,9 +113,9 @@ class WebBrowser :
112113
// IUnknown methods
113114
//---------------------------------------------------------------------------
114115
protected:
115-
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject);
116-
ULONG STDMETHODCALLTYPE AddRef(void);
117-
ULONG STDMETHODCALLTYPE Release(void);
116+
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject) NOEXCEPT_17;
117+
ULONG STDMETHODCALLTYPE AddRef(void) NOEXCEPT_17;
118+
ULONG STDMETHODCALLTYPE Release(void) NOEXCEPT_17;
118119

119120
//---------------------------------------------------------------------------
120121
// IBrowserDispatch methods

GeneralsMD/Code/GameEngine/Source/GameNetwork/WOLBrowser/WebBrowser.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ WebBrowserURL * WebBrowser::makeNewURL(AsciiString tag)
237237
*
238238
******************************************************************************/
239239

240-
STDMETHODIMP WebBrowser::QueryInterface(REFIID iid, void** ppv)
240+
STDMETHODIMP WebBrowser::QueryInterface(REFIID iid, void** ppv) NOEXCEPT_17
241241
{
242242
*ppv = NULL;
243243

@@ -270,7 +270,7 @@ STDMETHODIMP WebBrowser::QueryInterface(REFIID iid, void** ppv)
270270
*
271271
******************************************************************************/
272272

273-
ULONG STDMETHODCALLTYPE WebBrowser::AddRef(void)
273+
ULONG STDMETHODCALLTYPE WebBrowser::AddRef(void) NOEXCEPT_17
274274
{
275275
return ++mRefCount;
276276
}
@@ -290,7 +290,7 @@ ULONG STDMETHODCALLTYPE WebBrowser::AddRef(void)
290290
*
291291
******************************************************************************/
292292

293-
ULONG STDMETHODCALLTYPE WebBrowser::Release(void)
293+
ULONG STDMETHODCALLTYPE WebBrowser::Release(void) NOEXCEPT_17
294294
{
295295
DEBUG_ASSERTCRASH(mRefCount > 0, ("Negative reference count"));
296296
--mRefCount;

GeneralsMD/Code/Libraries/Source/WWVegas/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ target_compile_definitions(z_wwcommon INTERFACE
99
target_link_libraries(z_wwcommon INTERFACE
1010
d3d8lib
1111
gz_config
12+
gz_utility
1213
milesstub
1314
stlport
1415
)

0 commit comments

Comments
 (0)