-
Notifications
You must be signed in to change notification settings - Fork 90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use {fmt} for all string formatting #1847
Conversation
For some reason, using fmt has caused the linker to chuck these out? Maybe weren't ODR-used before. C++17 fixes this with inline variables, sigh.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One issue is that fmt will accept, say, %s in a string, but won't format it, and will happily take more variables than format specifiers in strings. So we might need to be careful there.
So one can use %s?
Right now gcc warns (if I remember correctly) if the string modifiers do not match the arguments. So this would mean we get less warnings then we do now?
Sorry, I wasn't clear: There is a macro, * Actually, we could, as fmt does have |
Thanks @ZedThree ! I think this is a slightly painful change, but it has some really nice advantages and is a big improvement. |
Positional arguments used a POSIX extension e.g `%2$s` to re-order arguments. This is converted to e.g. `{1:s}`. Note that whereas the printf numbering is from 1, fmt numbering is from 0.
`%s` -> `{:s}` `%d` -> `{:d}`
Add fmtlib locale corrections
Was relative path from BOUT_TOP, but BOUT_TOP was not expanded as expected. Instead, set FMT_INCLUDE_PATH variable in all required places which is set to absolute path at configure time
The failing tests in the push build are fixed in next, which is why the PR tests are passing. |
Another big PR late on a Friday, sorry!
We now use fmt for all our string formatting, instead of the printf-style formatting. This affects calls to
Output
,BoutException
/ParseException
,DataFile
,OptionsReader
, andMsgStack
/TRACE
. Runbin/bout-v5-format-upgrader.py
on your physics models to update them.One big benefit of fmt is that
{}
will format any standard type correctly, and we can customise it to work with our types too. This PR uses the more specific{:s}
,{:e}
syntax because the upgrader tool preserves and corrects the existing specifier.This will absolutely certainly cause conflicts with everything, but after merging
next
(either into this, or after this is merged, into your branch) runningbin/bout-v5-format-upgrader.py
on the affected files should fix things!You may also need to run that tool on any files you've changed.
One issue is that
fmt
will accept, say,%s
in a string, but won't format it, and will happily take more variables than format specifiers in strings. So we might need to be careful there.