[cfe-dev] printf-like function.
JF Knudsen via cfe-dev
cfe-dev at lists.llvm.org
Fri Mar 20 07:14:52 PDT 2020
There is no contradictions.
fmt doesn't work with C. I'm also using C++ in freestanding env without
STL on small devices with no dynamic memory allocation.
I still think that would be a nice addition, with no need to modify
existing libraries.
On 20.03.20 17:06, Keane, Erich via cfe-dev wrote:
> What about the fmt library? https://github.com/fmtlib/fmt
>
> A version of this was accepted to the c++20 spec, so in addition it'll be portable.
>
> -----Original Message-----
> From: cfe-dev <cfe-dev-bounces at lists.llvm.org> On Behalf Of JF Knudsen via cfe-dev
> Sent: Thursday, March 19, 2020 11:53 PM
> To: cfe-dev at lists.llvm.org
> Subject: [cfe-dev] printf-like function.
>
> Hi all,
>
> I'm a printf-like function lover. I always found that better than doing something like out << "blabla : " << var1 << ", blabla" << etc.
>
> Now, I use a lot of different platforms and to be portable, I'm supposed to use PRIxxx constants for portability. For me that half-breaks the readability of printf format.
>
> What about a new set of functions that'll be specified slightly differently :
>
> accepting %d for ANY number ? The compiler can modify the format litteral at compile time to fit what's needed for that platform, replacing %d by %hhd, %hd, %d, %ld, %lld, %hhu etc..
> Replacing the litteral format at compile time prevents to modify the vararg mechanism.
>
> Of course, if format is not litteral : no replacement !
>
> OR
>
> 2bis) some attributes could be passed on to this function so it'll know what to expect at runtime. I'm guessing modifying vararg mechanism to add attributes might be nearly impossible...
>
>
> I'm interested of what would you all think about that ?
>
> Thanks.
>
>
> PS : we could do the same with %s that could accept char*, wchar_t*, char16_t*, char32_t*.
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
More information about the cfe-dev
mailing list