]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Fix std::print for Cygwin
authorJonathan Wakely <jwakely@redhat.com>
Wed, 21 Feb 2024 18:10:00 +0000 (18:10 +0000)
committerJonathan Wakely <jwakely@redhat.com>
Wed, 28 Feb 2024 11:27:46 +0000 (11:27 +0000)
Cygwin should use std::fwrite, not WriteConsoleW. And the -lstdc++exp
library is only needed when running the tests on *-*-mingw*.

libstdc++-v3/ChangeLog:

* include/std/ostream (vprint_unicode) [__CYGWIN__]: Use POSIX
code path for Cygwin instead of Windows.
* include/std/print (vprint_unicode) [__CYGWIN__]: Likewise.
* testsuite/27_io/basic_ostream/print/1.cc: Only add -lstdc++exp
for *-*-mingw* targets.
* testsuite/27_io/print/1.cc: Likewise.

libstdc++-v3/include/std/ostream
libstdc++-v3/include/std/print
libstdc++-v3/testsuite/27_io/basic_ostream/print/1.cc
libstdc++-v3/testsuite/27_io/print/1.cc

index 7d501d67489e9a76e35eab346800903b20bf5632..a136399ad0b915acafed9c6abf10cf2e28b8fb38 100644 (file)
@@ -906,7 +906,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   inline void
   vprint_unicode(ostream& __os, string_view __fmt, format_args __args)
   {
-#ifndef _WIN32
+#if !defined(_WIN32) || defined(__CYGWIN__)
     // For most targets we don't need to do anything special to write
     // Unicode to a terminal.
     std::vprint_nonunicode(__os, __fmt, __args);
@@ -923,7 +923,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        // If stream refers to a terminal, write a Unicode string to it.
        if (auto __term = __open_terminal(__os.rdbuf()))
          {
-#ifndef _WIN32
+#if !defined(_WIN32) || defined(__CYGWIN__)
            // For POSIX, __open_terminal(streambuf*) uses fdopen to open a
            // new file, so we would need to close it here. This code is not
            // actually compiled because it's inside an #ifdef _WIN32 group,
index 492f333dfa6ed1e54d3913065b381046224f5cad..d44033469de2b542434baa2f9102ca66bd1597eb 100644 (file)
@@ -64,7 +64,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   inline void
   vprint_unicode(FILE* __stream, string_view __fmt, format_args __args)
   {
-#ifndef _WIN32
+#if !defined(_WIN32) || defined(__CYGWIN__)
     // For most targets we don't need to do anything special to write
     // Unicode to a terminal.
     std::vprint_nonunicode(__stream, __fmt, __args);
index b3abc570d1e1622ee975f7f69264cbe340077d1e..71a4daa04c90e0e293715a36cd1e11b994860cb1 100644 (file)
@@ -1,4 +1,4 @@
-// { dg-options "-lstdc++exp" }
+// { dg-additional-options "-lstdc++exp" { target { *-*-mingw* } } }
 // { dg-do run { target c++23 } }
 // { dg-require-fileio "" }
 
index 3cfdac1bb74db4cfa30b1a10b5d8d17d430c502b..6a294e0454b7b8364a37069e8beb4716155fae0a 100644 (file)
@@ -1,4 +1,4 @@
-// { dg-options "-lstdc++exp" }
+// { dg-additional-options "-lstdc++exp" { target { *-*-mingw* } } }
 // { dg-do run { target c++23 } }
 // { dg-require-fileio "" }