|
Boost : |
From: Christopher Kormanyos (e_float_at_[hidden])
Date: 2025-01-17 21:15:57
>>> BOOST_DECIMAL_DISABLE_CLIB ifdefs-out>>> entire headers - wouldn't it be simpler>>> to have a subset of headers allowable>>> in embedded systems, with others just>>> labelled as "not supported"?
Detailed comments follow below, butI personally doubt if there wouldbe anything remotely simple about havingdifferent amounts of headers. To the contrary,it would add more complexity.
It has been a while since we invented thesecompiler switches and I actually needed toreview them myself.
BOOST_DECIMAL_DISABLE_CLIB seems to begoing in the direction (if you follow this)of the freestanding movement in C++26.Basically, BOOST_DECIMAL_DISABLE_CLIBdisables all potentially heavyweightcomponents. I can list what these arein a second post. So you might notget <string> or <charconv>-like supporton the metal.
BOOST_DECIMAL_DISABLE_CLIB has the secondaryeffect of *also* definingBOOST_DECIMAL_DISABLE_IOSTREAM (see below).Disabling I/O streaming only cuts outheaders like <iostream>, <sstream> andtheir buddies.
>> The functions are only used in tests>> because they are for the end user.>> We have no need for streaming in the>> implementation. Since this is a>> header-only library I am not worried>> about library incompatibilities from>> different configurations.
> I think we might be talking about different> things here. Grepping for> BOOST_DECIMAL_DISABLE_IOSTREAM,> it protects the following functions:>Â * debug_pattern: not documented and>Â Â excluded from coverage>Â * bit_string: not documented>Â * Streaming native/emulated,>Â Â signed/unsigned 128/256 integer types,>Â Â all of which are in namespace detail.
BOOST_DECIMAL_DISABLE_IOSTREAM does prettymuch *literally what it says. It disablesI/O streaming functions.
In contrast to BOOST_DECIMAL_DISABLE_CLIB,which disables a lot more like <string>and the like and a bunch of stuff that'snot already by its nature more or lessfreestanding.
To be honest, I am completely satisfiedwith the inner workings of these compileroptions at the moment. We don't havefreestanding yet, so this situationsort of mocks that up.
On Friday, January 17, 2025 at 08:36:06 PM GMT+1, Ruben Perez via Boost <boost_at_[hidden]> wrote:
>
> > > I never tried many of the permutations of headers outside of the convenience one. The library is structured to match the STL so that it is unsurprising to the average user. I think you could pick and choose if you wanted to.
> >
>
> >
>
> > I tried picking charconv and it didn't work :)
> >
>
> > I think that the actual header structure is good, matching STL as you
> > said. I don't agree with recommending users to always include the
> > entire library - I think that increases compile times without much
> > benefit. Hence I was asking whether there was an actual reason to do
> > it.
> >
>
>
> So there's things I have to manually set that most never worry about for builtin types like global rounding mode and float evaluation method. Some impl headers need forward declarations of the types, some don't. It's pretty convenient from a design perspective to make things just work with no effort on the part of the user. I'm sure everything could be made to work piecemeal, but for a difference of maybe 3 seconds of compile time it's not worth the effort.
I'm afraid I don't agree here. Since this is a header-only library,
this is 3 seconds added to both direct and indirect users of the
library. If all Boost libraries did this, compile times would become
unmanageable. Also, Boost doesn't have the best reputation in this
aspect, so I think taking care of this is valuable.
Having a set of public headers that work is established practice in
Boost, and I'd advise to follow it.
>
> > > > 3. In the line of the previous question, is there a reason to have
> > > > BOOST_DECIMAL_DISABLE_IOSTREAM instead of splitting iostream
> > > > functionality to a separate header? In my experience, the more config
> > > > macros you have, the more chances of getting bugs. Also, is the test
> > > > suite being run with these macros defined?
> > >
>
> > > We have a the options to disable a bunch of the clib functionality so that the library can run on embedded platforms. We do have QEMU of an STM board in the CI which tests all of this. Why test embedded you ask? It's not uncommon for finance devs to run on bare metal platforms.
> >
>
> >
>
> > I understand the objective, and I think it's great having tests for
> > that. But I don't think the method is the best.
> >
>
> > I've reviewed all uses of BOOST_DECIMAL_DISABLE_IOSTREAM, and if I'm
> > reading this correctly, they all guard functions that are exclusively
> > used in the tests. I don't think these functions should be in the
> > headers shipped to users, but in the tests.
> >
>
> > I acknowledge that these functions require access to private members
> > of public classes, so I guess that's why they are defined there. I use
> > a dummy friend struct placed in the detail namespace when I have such
> > problems (I think I copied the pattern from Boost.Json). I think you
> > can get rid of all the iostream includes altogether doing this (except
> > for the ones in io.hpp, which are actually not guarded by the macro).
> >
>
> > BOOST_DECIMAL_DISABLE_CLIB ifdefs-out entire headers - wouldn't it be
> > simpler to have a subset of headers allowable in embedded systems,
> > with others just labelled as "not supported"?
>
> The functions are only used in tests because they are for the end user. We have no need for streaming in the implementation. Since this is a header-only library I am not worried about library incompatibilities from different configurations.
I think we might be talking about different things here. Grepping for
BOOST_DECIMAL_DISABLE_IOSTREAM, it protects the following functions:
* debug_pattern: not documented and excluded from coverage
* bit_string: not documented
* Streaming native/emulated, signed/unsigned 128/256 integer types,
all of which are in namespace detail.
Is the end user expected to use any of these?
>
> Matt
Regards,
Ruben.
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk