Skip to content
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

Allow disabling floating point support #1590

Merged
merged 4 commits into from
Mar 20, 2020
Merged

Conversation

albaguirre
Copy link
Contributor

Add FMT_USE_FLOAT, FMT_USE_DOUBLE and FMT_USE_LONG_DOUBLE to allow a
user of the library to configure the float types they want to allow.
This is specially useful in embedded environements where code size is
important.

I agree that my contributions are licensed under the {fmt} license, and agree to future changes to the licensing.

Add FMT_USE_FLOAT, FMT_USE_DOUBLE and FMT_USE_LONG_DOUBLE to allow a
user of the library to configure the float types they want to allow.
This is specially useful in embedded environements where code size is
important.
@vitaut
Copy link
Contributor

vitaut commented Mar 14, 2020

Thanks for the PR. Have you verified that this indeed results in smaller binary code? Could you provide any specific numbers?

@albaguirre
Copy link
Contributor Author

Thanks for the PR. Have you verified that this indeed results in smaller binary code? Could you provide any specific numbers?

Yeah on our current image, stripped and compiled with -0s using the GCC 4.8 bare metal toolchain (available at https://launchpad.net/gcc-arm-embedded/+download) we save the following:

FMT_USE_FLOAT=1 FMT_USE_DOUBLE=1 FMT_USE_LONG_DOUBLE=0
Saves 3264 bytes

FMT_USE_FLOAT=1 FMT_USE_DOUBLE=0 FMT_USE_LONG_DOUBLE=0
Saves 3696 bytes

FMT_USE_FLOAT=0 FMT_USE_DOUBLE=0 FMT_USE_LONG_DOUBLE=0
saves 12664 bytes

@vitaut
Copy link
Contributor

vitaut commented Mar 14, 2020

Do you need partial float support? If not I'd suggest having just one control to enable/disable all floating-point formatting instead of doing it type-by-type.

@albaguirre
Copy link
Contributor Author

Do you need partial float support? If not I'd suggest having just one control to enable/disable all floating-point formatting instead of doing it type-by-type.

Yes, on some platforms we need single precision float formatting, but not double or long double.

Copy link
Contributor

@vitaut vitaut left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good in general but let's make it a bit less intrusive.

include/fmt/core.h Outdated Show resolved Hide resolved
include/fmt/format.h Outdated Show resolved Hide resolved
include/fmt/format.h Outdated Show resolved Hide resolved
include/fmt/format.h Outdated Show resolved Hide resolved
include/fmt/format.h Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants