[clang] [libc] [libc] Modular printf option (float only) (PR #147426)

Michael Jones via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 12 14:45:57 PST 2026


================
@@ -48,4 +48,24 @@
 
 // LIBC_COPT_PRINTF_NO_NULLPTR_CHECKS
 
+#ifdef LIBC_COPT_PRINTF_MODULAR
+#define LIBC_PRINTF_MODULE_DECL __attribute__((weak))
+#else
+#define LIBC_PRINTF_MODULE_DECL LIBC_INLINE
+#endif
+
+// LIBC_PRINTF_MODULE: Defines/declares a printf module.
+//
+// Usage: LIBC_PRINTF_MODULE((<signature>), { <body> })
+//
+// Note that the signature is parenthesized, but the body is not.
----------------
michaelrj-google wrote:

it seems like you want to add an attribute to the function, similar to what we do with LIBC_INLINE. Is there a reason you can't just put `LIBC_PRINTF_MODULE_DECL` in front of the function definitions? That seems like it would be simpler and would avoid putting the body of the function inside the macro.

https://github.com/llvm/llvm-project/pull/147426


More information about the cfe-commits mailing list