From 30819d9e8559fc1f10ba82b3f9a086956aa6c8e2 Mon Sep 17 00:00:00 2001 From: Martchus Date: Tue, 28 Feb 2023 20:58:02 +0100 Subject: [PATCH] Improve condition for use of `pubsetbuf` Using this function like this seems only be possible with `libstdc++`. The standard lib of MSVC and Clang both don't support this (so it is not just MSVC and thus not Windows-specific). --- tests/iotests.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/iotests.cpp b/tests/iotests.cpp index a4ad84e..e266d39 100644 --- a/tests/iotests.cpp +++ b/tests/iotests.cpp @@ -185,7 +185,7 @@ void IoTests::testBinaryWriter() stringstream outputStream(ios_base::in | ios_base::out | ios_base::binary); outputStream.exceptions(ios_base::failbit | ios_base::badbit); char testData[397]; -#if !defined(PLATFORM_WINDOWS) || defined(PLATFORM_MINGW) || defined(PLATFORM_CYGWIN) +#if defined(__GLIBCXX__) && !defined(_LIBCPP_VERSION) #define USE_RDBUF_DIRECTLY outputStream.rdbuf()->pubsetbuf(testData, sizeof(testData)); #endif @@ -248,7 +248,11 @@ void IoTests::testBinaryWriter() "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901" "234567890123456789012345678901234567890123456789012345678901234567890123456789"); writer.writeTerminatedString("def"); - outputStream.flush(); + +#ifndef USE_RDBUF_DIRECTLY + outputStream.seekg(0); + outputStream.read(testData, 58); +#endif // test written values for (char c : testData) {