Skip to content

Commit

Permalink
restore C++17
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Smith committed Aug 18, 2023
1 parent 547d0aa commit d6efa7e
Show file tree
Hide file tree
Showing 44 changed files with 187 additions and 148 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.14)
project(nitro)

set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD 17)
set(CXX_STANDARD_REQUIRED true)

if (${CMAKE_PROJECT_NAME} STREQUAL nitro)
Expand Down
7 changes: 6 additions & 1 deletion UnitTest/UnitTest.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@
<EnforceTypeConversionRules>true</EnforceTypeConversionRules>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<ConformanceMode>true</ConformanceMode>
<LanguageStandard>stdcpp17</LanguageStandard>
<LanguageStandard_C>stdc11</LanguageStandard_C>
<UseStandardPreprocessor>true</UseStandardPreprocessor>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
Expand All @@ -86,11 +89,13 @@
<UseFullPaths>true</UseFullPaths>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<EnableEnhancedInstructionSet>AdvancedVectorExtensions2</EnableEnhancedInstructionSet>
<ControlFlowGuard>Guard</ControlFlowGuard>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<EnforceTypeConversionRules>true</EnforceTypeConversionRules>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<ConformanceMode>true</ConformanceMode>
<LanguageStandard>stdcpp17</LanguageStandard>
<LanguageStandard_C>stdc11</LanguageStandard_C>
<UseStandardPreprocessor>true</UseStandardPreprocessor>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
Expand Down
1 change: 1 addition & 0 deletions UnitTest/pch.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#define NOMINMAX
#pragma warning(push)
#pragma warning(disable: 5039) // '...': pointer or reference to potentially throwing function passed to 'extern "C"' function under -EHc. Undefined behavior may occur if this function throws an exception.
#pragma warning(disable: 5105) // macro expansion producing '...' has undefined behavior
#include <windows.h>
#pragma warning(pop)
#pragma comment(lib, "ws2_32")
Expand Down
2 changes: 1 addition & 1 deletion copy_externals.csh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/csh -f

rm -r -f tmp && mkdir tmp && cd tmp
git clone --depth 1 -b main [email protected]:mdaus/coda-oss.git
git clone --depth 1 -b cpp17 [email protected]:mdaus/coda-oss.git
rm -r -f coda-oss/.git

cd ..
Expand Down
6 changes: 5 additions & 1 deletion externals/coda-oss/.github/workflows/build_unittest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ jobs:
which python
mkdir target
cd target
export CC=gcc-11
export CXX=g++-11
cmake .. -DCMAKE_INSTALL_PREFIX=install${{ matrix.os }}CMake-Github -DPYTHON_VERSION=${{ matrix.python-version }} -DENABLE_SWIG=ON
- name: build
run: |
Expand All @@ -130,7 +132,7 @@ jobs:
build-waf:
strategy:
matrix:
os: [ubuntu-latest, windows-2019]
os: [ubuntu-latest]
python-version: ['3.7']
debugging: ['--enable-debugging', '']
name: ${{ matrix.os }}-${{ matrix.python-version }}-waf${{ matrix.debugging }}
Expand All @@ -146,6 +148,8 @@ jobs:
run: |
pip install numpy
mkdir install${{ matrix.os }}Waf-Github
export CC=gcc-11
export CXX=g++-11
python waf configure --prefix="$PWD/install${{ matrix.os }}Waf-Github" --enable-swig ${{ matrix.debugging }}
- name: configure_without_swig
if: ${{ matrix.os == 'windows-2019' }}
Expand Down
2 changes: 1 addition & 1 deletion externals/coda-oss/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
cmake_minimum_required(VERSION 3.14)
project(coda-oss)

set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD 17)
set(CXX_STANDARD_REQUIRED true)

if (EXISTS "${CMAKE_BINARY_DIR}/conanbuildinfo.cmake")
Expand Down
5 changes: 5 additions & 0 deletions externals/coda-oss/UnitTest/UnitTest.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@
<ConformanceMode>true</ConformanceMode>
<AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>
<EnableEnhancedInstructionSet>AdvancedVectorExtensions2</EnableEnhancedInstructionSet>
<LanguageStandard>stdcpp17</LanguageStandard>
<LanguageStandard_C>stdc11</LanguageStandard_C>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
Expand All @@ -96,6 +99,8 @@
<ConformanceMode>true</ConformanceMode>
<AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>
<EnableEnhancedInstructionSet>AdvancedVectorExtensions2</EnableEnhancedInstructionSet>
<LanguageStandard>stdcpp17</LanguageStandard>
<LanguageStandard_C>stdc11</LanguageStandard_C>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
Expand Down
17 changes: 5 additions & 12 deletions externals/coda-oss/build/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,7 @@ def options(opt):
opt.add_option('--enable-debugging', action='store_true', dest='debugging',
help='Enable debugging')
opt.add_option('--enable-cpp11', action='callback', callback=deprecated_callback)
opt.add_option('--enable-cpp17', action='store_true', dest='enablecpp17')
opt.add_option('--enable-cpp17', action='callback', callback=deprecated_callback)
opt.add_option('--enable-64bit', action='callback', callback=deprecated_callback)
opt.add_option('--enable-32bit', action='callback', callback=deprecated_callback)
opt.add_option('--with-cflags', action='store', nargs=1, dest='cflags',
Expand Down Expand Up @@ -812,7 +812,7 @@ def options(opt):
'results. NOOP if junit_xml cannot be imported')


def ensureCpp14Support(self):
def ensureCpp17Support(self):
# DEPRECATED.
# Keeping for now in case downstream code is still looking for it
self.env['cpp11support'] = True
Expand Down Expand Up @@ -914,10 +914,7 @@ def configureCompilerOptions(self):
config['cxx']['optz_fastest-possible'] = [ config['cxx']['optz_faster'], '-march=native' ] # -march=native instead of haswell

self.env.append_value('CXXFLAGS', '-fPIC'.split())
if not Options.options.enablecpp17:
gxxCompileFlags='-std=c++14'
else:
gxxCompileFlags='-std=c++17'
gxxCompileFlags='-std=c++17'
self.env.append_value('CXXFLAGS', gxxCompileFlags.split())

# DEFINES and LINKFLAGS will apply to both gcc and g++
Expand Down Expand Up @@ -1027,11 +1024,7 @@ def configureCompilerOptions(self):
'WIN32 _USE_MATH_DEFINES NOMINMAX _CRT_SECURE_NO_WARNINGS WIN32_LEAN_AND_MEAN'.split()
flags = '/UUNICODE /U_UNICODE /EHs /GR'.split()

#If building with cpp17 add flags/defines to enable auto_ptr
if Options.options.enablecpp17:
flags.append('/std:c++17')
else:
flags.append('/std:c++14')
flags.append('/std:c++17')

self.env.append_value('DEFINES', defines)
self.env.append_value('CXXFLAGS', flags)
Expand Down Expand Up @@ -1252,7 +1245,7 @@ def configure(self):
if Options.options._defs:
env.append_unique('DEFINES', Options.options._defs.split(','))
configureCompilerOptions(self)
ensureCpp14Support(self)
ensureCpp17Support(self)

env['PLATFORM'] = sys_platform

Expand Down
1 change: 0 additions & 1 deletion externals/coda-oss/modules/c++/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
set(TARGET_LANGUAGE c++)

# turn on maximum warnings
if (MSVC)
# By default, there is a /W3 on the command-line from somewhere (?); adding
# /Wn results in a compiler warning.
Expand Down
6 changes: 6 additions & 0 deletions externals/coda-oss/modules/c++/coda-oss.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,9 @@
<EnableEnhancedInstructionSet>AdvancedVectorExtensions2</EnableEnhancedInstructionSet>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<TreatWarningAsError>true</TreatWarningAsError>
<LanguageStandard>stdcpp17</LanguageStandard>
<LanguageStandard_C>stdc11</LanguageStandard_C>
<UseStandardPreprocessor>true</UseStandardPreprocessor>
</ClCompile>
<Link>
<SubSystem>
Expand Down Expand Up @@ -612,6 +615,9 @@
<ConformanceMode>true</ConformanceMode>
<AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>
<EnableEnhancedInstructionSet>AdvancedVectorExtensions2</EnableEnhancedInstructionSet>
<LanguageStandard>stdcpp17</LanguageStandard>
<LanguageStandard_C>stdc11</LanguageStandard_C>
<UseStandardPreprocessor>true</UseStandardPreprocessor>
</ClCompile>
<Link>
<SubSystem>
Expand Down
3 changes: 0 additions & 3 deletions externals/coda-oss/modules/c++/coda-oss.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@
<ClInclude Include="coda_oss\include\coda_oss\optional.h">
<Filter>coda_oss</Filter>
</ClInclude>
<ClInclude Include="coda_oss\include\coda_oss\optional_.h">
<Filter>coda_oss</Filter>
</ClInclude>
<ClInclude Include="coda_oss\include\coda_oss\span.h">
<Filter>coda_oss</Filter>
</ClInclude>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@
#define CODA_OSS_cpp20 (CODA_OSS_cplusplus >= CODA_OSS_cplusplus20)
#define CODA_OSS_cpp23 (CODA_OSS_cplusplus >= CODA_OSS_cplusplus23)

#if !CODA_OSS_cpp14
#error "Must compile with C++14 or greater."
#if !CODA_OSS_cpp17
#error "Must compile with C++17 or greater."
#endif

// Get feature-testing macros: https://en.cppreference.com/w/cpp/feature_test
Expand Down
17 changes: 2 additions & 15 deletions externals/coda-oss/modules/c++/coda_oss/include/coda_oss/cstddef.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,15 @@
* License along with this program; If not, http://www.gnu.org/licenses/.
*
*/
#pragma once
#ifndef CODA_OSS_coda_oss_cstddef_h_INCLUDED_
#define CODA_OSS_coda_oss_cstddef_h_INCLUDED_
#pragma once

#include <stdint.h>

#include <cstddef>
#include <type_traits>

// Need a fairly decent C++ compiler to use the real GSL. This brings in more than
// we really need for span (e.g., gsl::narrow()), but it keeps things simple.
#include "gsl/gsl.h" // not gsl/byte; need #pragma here to turn off warnings

namespace coda_oss
{
#if defined(GSL_BYTE_H) // the above #include'd gsl/byte
using gsl::byte;
#else // no gsl::byte, use our own
// https://en.cppreference.com/w/cpp/types/byte
enum class byte : unsigned char {};
#endif // GSL_BYTE_H
using byte = std::byte;
}
static_assert(!std::is_same<coda_oss::byte, uint8_t>::value, "'coda_oss::byte' should be a unique type.");

#endif // CODA_OSS_coda_oss_cstddef_h_INCLUDED_
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@

#include <type_traits>

#include "CPlusPlus.h"

#include "coda_oss/namespace_.h"
namespace coda_oss
{
Expand Down
15 changes: 4 additions & 11 deletions externals/coda-oss/modules/c++/io/include/io/FileInputStreamIOS.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,15 @@
#include <ios>
#include <iostream>
#include <fstream>
#include <std/filesystem>

#include "except/Exception.h"
#include "sys/filesystem.h"
#include "io/InputStream.h"
#include "io/SeekableStreams.h"

#include "sys/CPlusPlus.h"
#if CODA_OSS_cpp17
#include <std/filesystem>
#endif

/*!

/*!
* \file FileInputStreamIOS.h
* \brief The InputStream representation of a file
* \todo Redefine the readln function to use getline()
Expand Down Expand Up @@ -70,13 +68,8 @@ class FileInputStreamIOS : public SeekableInputStream
* \param inputFile The file name
* \param mode The mode to open the file in
*/
FileInputStreamIOS(const coda_oss::filesystem::path& inputFile,
std::ios::openmode mode = std::ios::in);
#if CODA_OSS_cpp17
FileInputStreamIOS(const std::filesystem::path& inputFile,
std::ios::openmode mode = std::ios::in);
#endif


/*!
* Alternate Constructor. Takes an input file and a mode
Expand Down
18 changes: 5 additions & 13 deletions externals/coda-oss/modules/c++/io/include/io/FileOutputStreamOS.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,15 @@
#pragma once

#include <string>
#include <std/filesystem>

#include "config/Exports.h"

#if !defined(USE_IO_STREAMS)

#include "io/SeekableStreams.h"
#include "sys/filesystem.h"
#include "sys/File.h"

#include "sys/CPlusPlus.h"
#if CODA_OSS_cpp17
#include <std/filesystem>
#endif

/*!
* \file FileOutputStream.h
* \brief The OutputStream representation of a file
Expand All @@ -64,17 +59,14 @@ class CODA_OSS_API FileOutputStreamOS : public SeekableOutputStream
public:
FileOutputStreamOS() = default;

using path = std::filesystem::path; // still used in SWIG bindings

/*!
* Alternate Constructor. Takes an output file and a mode
* \param outputFile The file name
* \param creationFlags see sys::File
*/
#if CODA_OSS_cpp17
using path = std::filesystem::path;
#else
using path = coda_oss::filesystem::path;
#endif
FileOutputStreamOS(const path& outputFile,
FileOutputStreamOS(const std::filesystem::path& outputFile,
int creationFlags = sys::File::CREATE | sys::File::TRUNCATE);

//! Destructor, closes the file stream.
Expand All @@ -100,7 +92,7 @@ class CODA_OSS_API FileOutputStreamOS : public SeekableOutputStream
* \param file The file to open
* \param creationFlags see sys::File
*/
virtual void create(const path& str,
virtual void create(const std::filesystem::path& str,
int creationFlags = sys::File::CREATE | sys::File::TRUNCATE);

//! Close the file
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@

#if !defined(USE_IO_STREAMS)

io::FileOutputStreamOS::FileOutputStreamOS(const path& str,
io::FileOutputStreamOS::FileOutputStreamOS(const std::filesystem::path& str,
int creationFlags)
{
mFile.create(str.string(), sys::File::WRITE_ONLY, creationFlags);
}

void io::FileOutputStreamOS::create(const path& str_,
void io::FileOutputStreamOS::create(const std::filesystem::path& str_,
int creationFlags)
{
const auto str = str_.string();
Expand Down
17 changes: 4 additions & 13 deletions externals/coda-oss/modules/c++/logging/include/logging/Setup.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,14 @@

#include <memory>
#include <string>
#include <std/filesystem>

#include "sys/filesystem.h"
#include "mem/SharedPtr.h"
#include "logging/Logger.h"

#include "sys/CPlusPlus.h"
#if CODA_OSS_cpp17
#include <std/filesystem>
#endif

namespace logging
{
using path = std::filesystem::path; // still used in SWIG bindings

/*!
* \fn setupLogger
Expand All @@ -52,15 +48,10 @@ namespace logging
* \param logCount - number of rotating logs to keep (default: 0 no rotation)
* \param logBytes - number of bytes per rotating log (default: 0 no rotation)
*/
#if CODA_OSS_cpp17
using path = std::filesystem::path;
#else
using path = coda_oss::filesystem::path;
#endif
std::unique_ptr<logging::Logger> setupLogger(
const path& program,
const std::filesystem::path& program,
const std::string& logLevel = "warning",
const path& logFile = "console",
const std::filesystem::path& logFile = "console",
const std::string& logFormat = "[%p] (%d) %m",
size_t logCount = 0,
size_t logBytes = 0);
Expand Down
Loading

0 comments on commit d6efa7e

Please sign in to comment.