[libcxx-commits] [PATCH] D98077: [libcxx] Fix the format strings for formatting paths in directory_iterator.cpp

Marek Kurdej via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Fri Mar 5 15:38:43 PST 2021

curdeius added inline comments.

Comment at: libcxx/src/filesystem/filesystem_common.h:115
+#define PS_FMT "%s"
Quuxplusone wrote:
> How about moving the escaped-double-quotes into this format string?
> ```
> #define PS_FMT "\"%ls\""
> #define PS_FMT "\"%s\""
> ```
> That'll make the call-sites look less wacky.
> (I admit it doesn't really make any sense that we double-quote these paths in the first place. It's not as if we're going to actually escape the backslashes/quotes //in// the paths; so the quotation marks are kind of a lie. But I don't feel like unilaterally suggesting their complete removal.)
Personally I'd go the opposite way and rather see these macros closer to PRIxYYx macros (cf. https://en.cppreference.com/w/c/types/integer) and so not even include the % sign. This way, they could be used in the future with additional format options, like width, between % and the macro.

#define PS_FMT "ls"
#define PS_FMT "s"
And put % in the format string. WDYT?

  rG LLVM Github Monorepo



More information about the libcxx-commits mailing list