[patch] Removal of strfwd.h (was: When to use strfwd.h)

Pavel Sanda sanda at lyx.org
Fri Oct 4 09:59:46 UTC 2024


On Fri, Oct 04, 2024 at 12:50:59AM +0200, Enrico Forestieri wrote:
> On Thu, Oct 03, 2024 at 11:33:18PM +0200, Pavel Sanda wrote:
> > On Thu, Oct 03, 2024 at 11:05:03PM +0200, Enrico Forestieri wrote:
> > > On Thu, Oct 03, 2024 at 10:04:04PM +0200, Enrico Forestieri wrote:
> > > >
> > > > On Thu, Oct 03, 2024 at 03:57:56PM +0200, Pavel Sanda wrote:
> > > > > On Thu, Oct 03, 2024 at 01:35:55AM +0200, Enrico Forestieri wrote:
> > > > > > And, after adding "#include <string>" to src/support/trivstring.h as
> > > > > > suggested, it fails in this new way:
> > > > >
> > > > > Adding "#include <ostream>" makes cygwin happy?
> > > >
> > > > It helps. Compilation proceeds until the following failure:
> > > 
> > > However, applying the attached patch it compiles and works fine.
> > > See https://www.mail-archive.com/lyx-devel@lists.lyx.org/msg219747.html for
> > > the reason the patch is right.
> > 
> > I was going to ask whether adding #include "support/trivstring.h" into
> > Format.h would work.
> 
> Yes, but trivstring.h has also to be included into Converter.h, maybe both
> guarded by "#ifdef STD_STRING_USES_COW"
> 
> > With removal of strfwd I moved
> > +#ifdef STD_STRING_USES_COW
> > +template<typename Char> class trivial_string;
> > +typedef trivial_string<char> trivstring;
> > +typedef trivial_string<char_type> trivdocstring;
> > +#else
> > +typedef std::string trivstring;
> > +typedef docstring trivdocstring;
> > +#endif
> > 
> > into docstring.h.
> > 
> > But I don't like it there as all trivstring stuff should imho go into
> > trivstring.h.
> > Before I was afraid what will break, but as I broke cygwin anyway, maybe
> > it's time
> > to get rid of this from docstring?
> 
> I am not sure what you mean.

The code snippet above is in docstring.h. I think it should be somehow
incorporated into trivstring.h instead.
(Unless we want to ditch trivstring altogether, per JMarcs' suggestion.)

> I don't think that it is right breaking compilation on systems where
> std::string uses cow, given that the solution is actually very simple.

Right.

> Anyway, I would like to apply the attached patch that actually checks
> whether std::string uses cow instead of inferring it from
> _GLIBCXX_USE_CXX11_ABI. Of course, the check cannot be performed when
> cross-compiling and in such a case the code assumes cow is used, as before.

Looks good to me.

Pavel


More information about the lyx-devel mailing list