diff --git a/source/adios2/helper/adiosSystem.cpp b/source/adios2/helper/adiosSystem.cpp index 9dcbd42f313b741a2555b5e07b7953fa71bdaa42..233f2d096cffde6bb1b482c75bcdcbbc5a36ee72 100644 --- a/source/adios2/helper/adiosSystem.cpp +++ b/source/adios2/helper/adiosSystem.cpp @@ -20,11 +20,8 @@ #include "adios2/helper/adiosString.h" // remove ctime warning on Windows -#ifdef _MSC_VER -#define _CRT_SECURE_NO_WARNINGS -#define _CRT_SECURE_NO_DEPRECATE -#define _SCL_SECURE_NO_WARNINGS -#define _SCL_SECURE_NO_DEPRECATE +#ifdef _WIN32 +#pragma warning(disable : 4996) #endif namespace adios2 diff --git a/source/adios2/mpidummy.cpp b/source/adios2/mpidummy.cpp index 763d9a6f36a7df161657d54c0afe7e2470cf8c01..b47c68a3476f7a78efb932cf59bcc6cc31ca4669 100644 --- a/source/adios2/mpidummy.cpp +++ b/source/adios2/mpidummy.cpp @@ -33,11 +33,10 @@ #include <chrono> #include <string> -#ifdef _MSC_VER -#define _CRT_SECURE_NO_WARNINGS -#define _CRT_SECURE_NO_DEPRECATE -#define _SCL_SECURE_NO_WARNINGS -#define _SCL_SECURE_NO_DEPRECATE +// remove warnings on Windows +#ifdef _WIN32 +#pragma warning(disable : 4996) // fopen +#pragma warning(disable : 4477) // strcpy, sprintf #endif namespace adios2 @@ -302,7 +301,7 @@ int MPI_File_open(MPI_Comm /*comm*/, const char *filename, int amode, } mode += "b"; - *fh = fopen(filename, mode.c_str()); + *fh = std::fopen(filename, mode.c_str()); if (!*fh) { std::snprintf(mpierrmsg, MPI_MAX_ERROR_STRING, "File not found: %s", @@ -316,10 +315,10 @@ int MPI_File_close(MPI_File *fh) { return fclose(*fh); } int MPI_File_get_size(MPI_File fh, MPI_Offset *size) { - long curpos = ftell(fh); + long curpos = std::ftell(fh); fseek(fh, 0, SEEK_END); // go to end, returned is the size in bytes - long endpos = ftell(fh); - fseek(fh, curpos, SEEK_SET); // go back where we were + long endpos = std::ftell(fh); + std::fseek(fh, curpos, SEEK_SET); // go back where we were *size = static_cast<MPI_Offset>(endpos); // printf("MPI_File_get_size: fh=%d, size=%lld\n", fh, *size); return MPI_SUCCESS; @@ -331,7 +330,7 @@ int MPI_File_read(MPI_File fh, void *buf, int count, MPI_Datatype datatype, // FIXME: int count can read only 2GB (*datatype size) array at max size_t bytes_to_read = static_cast<size_t>(count) * datatype; size_t bytes_read; - bytes_read = fread(buf, 1, bytes_to_read, fh); + bytes_read = std::fread(buf, 1, bytes_to_read, fh); if (bytes_read != bytes_to_read) { std::snprintf(mpierrmsg, MPI_MAX_ERROR_STRING, @@ -348,7 +347,7 @@ int MPI_File_read(MPI_File fh, void *buf, int count, MPI_Datatype datatype, int MPI_File_seek(MPI_File fh, MPI_Offset offset, int whence) { - return fseek(fh, offset, whence) == MPI_SUCCESS; + return std::fseek(fh, offset, whence) == MPI_SUCCESS; } int MPI_Get_count(const MPI_Status *status, MPI_Datatype, int *count) diff --git a/source/adios2/toolkit/capsule/heap/STLVector.cpp b/source/adios2/toolkit/capsule/heap/STLVector.cpp index 9ff852d3f2d76d5535cb57191ed87112234c2690..5221f00faa3245c66a14d3dd44708d34a40b1f81 100644 --- a/source/adios2/toolkit/capsule/heap/STLVector.cpp +++ b/source/adios2/toolkit/capsule/heap/STLVector.cpp @@ -41,10 +41,10 @@ void STLVector::ResizeData(const size_t size) { m_Data.resize(size); } - catch (std::bad_alloc &e) + catch (...) { std::throw_with_nested( - std::runtime_error("ERROR: bad_alloc detected when resizing " + std::runtime_error("ERROR: possible overflow when resizing " "data buffer with size " + std::to_string(size) + "\n")); } @@ -63,10 +63,10 @@ void STLVector::ResizeMetadata(const size_t size) { m_Metadata.resize(size); } - catch (std::bad_alloc &e) + catch (...) { std::throw_with_nested( - std::runtime_error("ERROR: bad_alloc detected when resizing " + std::runtime_error("ERROR: possible overflow when resizing " "metadata buffer with size " + std::to_string(size) + "\n")); } diff --git a/source/adios2/toolkit/transport/file/FilePointer.cpp b/source/adios2/toolkit/transport/file/FilePointer.cpp index 468b726e13c1f4db2dc0fa50cfc33f23b73ecb69..e11c4f9fb9dc17a6118f4cec5d8fc6f933061eb8 100644 --- a/source/adios2/toolkit/transport/file/FilePointer.cpp +++ b/source/adios2/toolkit/transport/file/FilePointer.cpp @@ -15,11 +15,8 @@ /// \endcond // removes fopen warning on Windows -#ifdef _MSC_VER -#define _CRT_SECURE_NO_WARNINGS -#define _CRT_SECURE_NO_DEPRECATE -#define _SCL_SECURE_NO_WARNINGS -#define _SCL_SECURE_NO_DEPRECATE +#ifdef _WIN32 +#pragma warning(disable : 4996) // fopen #endif namespace adios2 @@ -36,7 +33,7 @@ FilePointer::~FilePointer() { if (m_IsOpen) { - fclose(m_File); + std::fclose(m_File); } } @@ -56,16 +53,16 @@ void FilePointer::Open(const std::string &name, const OpenMode openMode) if (m_OpenMode == OpenMode::Write) { - m_File = fopen(name.c_str(), "wb"); + m_File = std::fopen(name.c_str(), "wb"); } else if (m_OpenMode == OpenMode::Append) { // need to change when implemented - m_File = fopen(name.c_str(), "ab"); + m_File = std::fopen(name.c_str(), "ab"); } else if (m_OpenMode == OpenMode::Read) { - m_File = fopen(name.c_str(), "rb"); + m_File = std::fopen(name.c_str(), "rb"); } if (ferror(m_File)) @@ -80,7 +77,7 @@ void FilePointer::Open(const std::string &name, const OpenMode openMode) void FilePointer::SetBuffer(char *buffer, size_t size) { - const int status = setvbuf(m_File, buffer, _IOFBF, size); + const int status = std::setvbuf(m_File, buffer, _IOFBF, size); if (!status) { @@ -98,7 +95,7 @@ void FilePointer::Write(const char *buffer, size_t size) { m_Profiler.Timers.at("write").Resume(); } - auto writtenSize = fwrite(buffer, sizeof(char), size, m_File); + auto writtenSize = std::fwrite(buffer, sizeof(char), size, m_File); if (m_Profiler.IsActive) { @@ -141,7 +138,7 @@ void FilePointer::Write(const char *buffer, size_t size) void FilePointer::Flush() { - const int status = fflush(m_File); + const int status = std::fflush(m_File); if (status == EOF) { @@ -157,7 +154,7 @@ void FilePointer::Close() m_Profiler.Timers.at("close").Resume(); } - const int status = fclose(m_File); + const int status = std::fclose(m_File); if (m_Profiler.IsActive) {