From 2d81acb82e1001ef9135f122ea87a8ef3e6a486b Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Fri, 11 Aug 2017 19:18:45 -0400 Subject: [PATCH] Upped C++ standard to C++14 and added an #if that's intended to use the built-in std::gcd when compiled on C++17 or better. Fixed for new signedness warnings resulting for taking the step to C++14. --- NumberTheory/Factors.hpp | 5 +++++ OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj | 2 ++ Outputs/CRT/Internals/Shaders/Shader.cpp | 4 ++-- Storage/FileHolder.cpp | 2 +- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/NumberTheory/Factors.hpp b/NumberTheory/Factors.hpp index 9fe660bc2..ad21a362f 100644 --- a/NumberTheory/Factors.hpp +++ b/NumberTheory/Factors.hpp @@ -9,6 +9,7 @@ #ifndef Factors_hpp #define Factors_hpp +#include #include namespace NumberTheory { @@ -16,6 +17,9 @@ namespace NumberTheory { @returns The greatest common divisor of @c a and @c b as computed by Euclid's algorithm. */ template T greatest_common_divisor(T a, T b) { +#if __cplusplus > 201402L + return std::gcd(a, b); +#else // TODO: replace with the C++17 GCD function, once available. if(a < b) { std::swap(a, b); @@ -29,6 +33,7 @@ namespace NumberTheory { a = b; b = remainder; } +#endif } /*! diff --git a/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj b/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj index f7a8f670a..b77bb0dd8 100644 --- a/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj +++ b/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj @@ -3037,6 +3037,7 @@ isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_CXX_LANGUAGE_STANDARD = "c++14"; CLANG_ENABLE_MODULES = YES; CLANG_WARN_ASSIGN_ENUM = YES; CLANG_WARN_DOCUMENTATION_COMMENTS = YES; @@ -3065,6 +3066,7 @@ isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_CXX_LANGUAGE_STANDARD = "c++14"; CLANG_ENABLE_MODULES = YES; CLANG_WARN_ASSIGN_ENUM = YES; CLANG_WARN_DOCUMENTATION_COMMENTS = YES; diff --git a/Outputs/CRT/Internals/Shaders/Shader.cpp b/Outputs/CRT/Internals/Shaders/Shader.cpp index 7d0c0a6b5..413932dc3 100644 --- a/Outputs/CRT/Internals/Shaders/Shader.cpp +++ b/Outputs/CRT/Internals/Shaders/Shader.cpp @@ -29,7 +29,7 @@ GLuint Shader::compile_shader(const std::string &source, GLenum type) { GLint logLength; glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &logLength); if(logLength > 0) { - GLchar *log = new GLchar[logLength]; + GLchar *log = new GLchar[(size_t)logLength]; glGetShaderInfoLog(shader, logLength, &logLength, log); printf("Compile log:\n%s\n", log); delete[] log; @@ -66,7 +66,7 @@ Shader::Shader(const std::string &vertex_shader, const std::string &fragment_sha GLint logLength; glGetProgramiv(shader_program_, GL_INFO_LOG_LENGTH, &logLength); if(logLength > 0) { - GLchar *log = new GLchar[logLength]; + GLchar *log = new GLchar[(size_t)logLength]; glGetProgramInfoLog(shader_program_, logLength, &logLength, log); printf("Link log:\n%s\n", log); delete[] log; diff --git a/Storage/FileHolder.cpp b/Storage/FileHolder.cpp index f447fadd8..9f78253ab 100644 --- a/Storage/FileHolder.cpp +++ b/Storage/FileHolder.cpp @@ -82,7 +82,7 @@ void FileHolder::ensure_file_is_at_least_length(long length) { long bytes_to_write = length - ftell(file_); if(bytes_to_write > 0) { - uint8_t *empty = new uint8_t[bytes_to_write]; + uint8_t *empty = new uint8_t[(size_t)bytes_to_write]; memset(empty, 0, (size_t)bytes_to_write); fwrite(empty, sizeof(uint8_t), (size_t)bytes_to_write, file_); delete[] empty;