[PATCH] libc++: Print log/error messages on stderr, not stdout

Ed Schouten ed at 80386.nl
Sat Mar 7 00:31:41 PST 2015


Hi EricWF, mclow.lists,

There are a couple of places where libc++ prints log/error messages to stdout on its own. This may of course interfere with the output generated with applications. Log/error messages should be directed to stderr instead.

http://reviews.llvm.org/D8135

Files:
  include/__debug
  src/exception.cpp

Index: include/__debug
===================================================================
--- include/__debug
+++ include/__debug
@@ -22,7 +22,7 @@
 #   include <cstdio>
 #   include <cstddef>
 #   ifndef _LIBCPP_ASSERT
-#      define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : (_VSTD::printf("%s\n", m), _VSTD::abort()))
+#      define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : (_VSTD::fprintf(stderr, "%s\n", m), _VSTD::abort()))
 #   endif
 #endif
 
Index: src/exception.cpp
===================================================================
--- src/exception.cpp
+++ src/exception.cpp
@@ -90,7 +90,7 @@
 #endif  // _LIBCPP_NO_EXCEPTIONS
         (*get_terminate())();
         // handler should not return
-        printf("terminate_handler unexpectedly returned\n");
+        fprintf(stderr, "terminate_handler unexpectedly returned\n");
         ::abort();
 #ifndef _LIBCPP_NO_EXCEPTIONS
     }
@@ -97,7 +97,7 @@
     catch (...)
     {
         // handler should not throw exception
-        printf("terminate_handler unexpectedly threw an exception\n");
+        fprintf(stderr, "terminate_handler unexpectedly threw an exception\n");
         ::abort();
     }
 #endif  // _LIBCPP_NO_EXCEPTIONS
@@ -117,7 +117,7 @@
 #   else
 #       warning uncaught_exception not yet implemented
 #   endif
-    printf("uncaught_exception not yet implemented\n");
+    fprintf(stderr, "uncaught_exception not yet implemented\n");
     ::abort();
 #endif  // __APPLE__
 }
@@ -190,7 +190,7 @@
 #   else
 #       warning exception_ptr not yet implemented
 #   endif
-    printf("exception_ptr not yet implemented\n");
+    fprintf(stderr, "exception_ptr not yet implemented\n");
     ::abort();
 #endif
 }
@@ -209,7 +209,7 @@
 #   else
 #       warning exception_ptr not yet implemented
 #   endif
-    printf("exception_ptr not yet implemented\n");
+    fprintf(stderr, "exception_ptr not yet implemented\n");
     ::abort();
 #endif
 }
@@ -234,7 +234,7 @@
 #   else
 #       warning exception_ptr not yet implemented
 #   endif
-    printf("exception_ptr not yet implemented\n");
+    fprintf(stderr, "exception_ptr not yet implemented\n");
     ::abort();
 #endif
 }
@@ -278,7 +278,7 @@
 #   else
 #       warning exception_ptr not yet implemented
 #   endif
-    printf("exception_ptr not yet implemented\n");
+    fprintf(stderr, "exception_ptr not yet implemented\n");
     ::abort();
 #endif
 }
@@ -300,7 +300,7 @@
 #   else
 #       warning exception_ptr not yet implemented
 #   endif
-    printf("exception_ptr not yet implemented\n");
+    fprintf(stderr, "exception_ptr not yet implemented\n");
     ::abort();
 #endif
 }

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D8135.21417.patch
Type: text/x-patch
Size: 2618 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150307/0a62b8e3/attachment.bin>


More information about the cfe-commits mailing list