Open jaskij opened 9 months ago
It should be possible to add a macro to opt out of generating string conversions at all. I would strongly considering merging a PR. However, I understand from your message that you have a workaround for the main problem, so it might not be worth it. I understand that the remainder of this issue is about disabling string conversions for maybe safety or tidiness reasons. Is that right?
Mostly it's about code size. Depending on my own build configuration, I'm currently using over 90% of the allowed space. Better Enums without BETTER_ENUMS_CONSTEXPR_TO_STRING
would push me over 100%, causing the builds to fail. In this particular project, I have a hardware limit that my whole release binary must fit in 52k.
Yes, there is a workaround. Disabling those string conversions entirely is honestly just build times and simple cleanliness at this point.
I added Better Enums to my embedded project (a fantastic library by the way), and after converting two enums (one with 8 values, the other with 38), it added about 4 kiB of code size and 2 kiB of RAM usage. That may seem trivial, but in a device which has 64 kiB of flash and 8 kiB of RAM, it's a lot.
Experimenting a little, I found out that using
BETTER_ENUMS_CONSTEXPR_TO_STRING
has brought code size back down to what it was before using Better Enums. Which is fine, as is.The thing is, my project does not use string conversion at all, and I would like to opt out of it if possible.
P.S.
I'm using ARM's build of GCC 13.2, with
-Os -ffunction-sections -fdata-section
and passing-gc-sections
to the linker. Project is also compiled with LTO.