Replies: 1 comment 1 reply
-
|
%a ? never heard of it. It's not even in lists i find online.. Is that a Mac thing? We think generating a u64_format_b() for architectures that dont support it is fine . This could be implemented in just the generator. I dont want to solve all problems for everyone, so if they want to print their custom types, they have to solve it. Printf is quite generic, but i think allowing more argument might cause bugs (because people add their type instead of something else) |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Here is an idea to extend
printffor custom types and potentially custom conversions:There is a potential problem with
%band%aconversions in some architectures:clangcomplains on my macbook that%lbhas undefined behavior. For systems that do not support%bor%a, we could convert these formats into%s, passing the return value of a customformat_xtype function taking the format flags and the width and precision values:For example
u64 v = ...; printf("value: %#064b\n", v);could be turned intoMore generally, this system can be used for other unsupported formats, or for extended formats implemented as type functions:
Assuming a type function
Point.format_dis found with the appropriate prototype, this could generate:Beta Was this translation helpful? Give feedback.
All reactions