Skip to content

Commit

Permalink
Merge pull request #6273 from leoetlino/c++17
Browse files Browse the repository at this point in the history
Enable C++17
  • Loading branch information
leoetlino committed May 5, 2019
2 parents 99a4ca8 + 9133e8f commit 5d52b6f
Show file tree
Hide file tree
Showing 43 changed files with 118 additions and 3,629 deletions.
6 changes: 3 additions & 3 deletions CMakeLists.txt
@@ -1,7 +1,7 @@
########################################
# General setup
#
cmake_minimum_required(VERSION 3.5.0)
cmake_minimum_required(VERSION 3.10)
set(CMAKE_OSX_ARCHITECTURES "x86_64")
# Minimum OS X version.
# This is inserted into the Info.plist as well.
Expand Down Expand Up @@ -203,8 +203,8 @@ endif()


# Enforce minimum GCC version
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 6.0)
message(FATAL_ERROR "Dolphin requires at least GCC 6.0 (found ${CMAKE_CXX_COMPILER_VERSION})")
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.0)
message(FATAL_ERROR "Dolphin requires at least GCC 7.0 (found ${CMAKE_CXX_COMPILER_VERSION})")
endif()

if(CMAKE_GENERATOR MATCHES "Ninja")
Expand Down
1 change: 1 addition & 0 deletions Source/Android/app/build.gradle
Expand Up @@ -60,6 +60,7 @@ android {
externalNativeBuild {
cmake {
path "../../../CMakeLists.txt"
version "3.10.2"
}
}

Expand Down
23 changes: 3 additions & 20 deletions Source/CMakeLists.txt
Expand Up @@ -9,26 +9,9 @@ if(CMAKE_SYSTEM_NAME MATCHES "Windows")
add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
endif()

if(CMAKE_C_COMPILER_ID MATCHES "MSVC")
# enable the latest C++ standard feature set,
# and also disable MSVC specific extensions
# to be even more standards compliant.
check_and_add_flag(CPPLATEST /std:c++latest)
check_and_add_flag(STANDARD_COMPLIANCE /permissive-)
else()
# Enable C++17, but fall back to C++14 if it isn't available.
# CMAKE_CXX_STANDARD cannot be used here because we require C++14 or newer, not any standard.
check_and_add_flag(CXX17 -std=c++17)
if(NOT FLAG_CXX_CXX17)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
endif()

# These compat headers must not be in the include path when building with MSVC,
# because it currently does not support __has_include_next / #include_next.
include_directories(SYSTEM Core/Common/Compat)
endif()
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

# These aren't actually needed for C11/C++11
# but some dependencies require them (LLVM, libav).
Expand Down
10 changes: 5 additions & 5 deletions Source/Core/AudioCommon/Mixer.cpp
Expand Up @@ -4,13 +4,13 @@

#include "AudioCommon/Mixer.h"

#include <algorithm>
#include <cmath>
#include <cstring>

#include "Common/ChunkFile.h"
#include "Common/CommonTypes.h"
#include "Common/Logging/Log.h"
#include "Common/MathUtil.h"
#include "Common/Swap.h"
#include "Core/ConfigManager.h"

Expand Down Expand Up @@ -86,14 +86,14 @@ unsigned int Mixer::MixerFifo::Mix(short* samples, unsigned int numSamples,
int sampleL = ((l1 << 16) + (l2 - l1) * (u16)m_frac) >> 16;
sampleL = (sampleL * lvolume) >> 8;
sampleL += samples[currentSample + 1];
samples[currentSample + 1] = MathUtil::Clamp(sampleL, -32767, 32767);
samples[currentSample + 1] = std::clamp(sampleL, -32767, 32767);

s16 r1 = Common::swap16(m_buffer[(indexR + 1) & INDEX_MASK]); // current
s16 r2 = Common::swap16(m_buffer[(indexR2 + 1) & INDEX_MASK]); // next
int sampleR = ((r1 << 16) + (r2 - r1) * (u16)m_frac) >> 16;
sampleR = (sampleR * rvolume) >> 8;
sampleR += samples[currentSample];
samples[currentSample] = MathUtil::Clamp(sampleR, -32767, 32767);
samples[currentSample] = std::clamp(sampleR, -32767, 32767);

m_frac += ratio;
indexR += 2 * (u16)(m_frac >> 16);
Expand All @@ -111,8 +111,8 @@ unsigned int Mixer::MixerFifo::Mix(short* samples, unsigned int numSamples,
s[1] = (s[1] * lvolume) >> 8;
for (; currentSample < numSamples * 2; currentSample += 2)
{
int sampleR = MathUtil::Clamp(s[0] + samples[currentSample + 0], -32767, 32767);
int sampleL = MathUtil::Clamp(s[1] + samples[currentSample + 1], -32767, 32767);
int sampleR = std::clamp(s[0] + samples[currentSample + 0], -32767, 32767);
int sampleL = std::clamp(s[1] + samples[currentSample + 1], -32767, 32767);

samples[currentSample + 0] = sampleR;
samples[currentSample + 1] = sampleL;
Expand Down
45 changes: 0 additions & 45 deletions Source/Core/Common/Compat/in_place.h

This file was deleted.

0 comments on commit 5d52b6f

Please sign in to comment.