[libc-commits] [libc] [libc] Add printf error handling (PR #162876)
Michael Jones via libc-commits
libc-commits at lists.llvm.org
Fri Oct 10 10:42:09 PDT 2025
================
@@ -22,6 +22,18 @@
namespace LIBC_NAMESPACE_DECL {
namespace printf_core {
+struct PrintfResult {
+ size_t value;
+ int error;
+
+ constexpr PrintfResult(size_t val) : value(val), error(0) {}
+ constexpr PrintfResult(size_t val, int error) : value(val), error(error) {}
+
+ constexpr bool has_error() { return error != 0; }
+
+ constexpr operator size_t() { return value; }
+};
----------------
michaelrj-google wrote:
I'm not sure this struct is necessary since I don't think there are any cases where we want to both set errno and return the value, it's always one or the other. I'd recommend using the `ErrorOr` struct instead.
https://github.com/llvm/llvm-project/pull/162876
More information about the libc-commits
mailing list