When to use strfwd.h

Jean-Marc Lasgouttes lasgouttes at lyx.org
Tue Oct 1 09:12:00 UTC 2024


Le 01/10/2024 à 10:50, Pavel Sanda a écrit :
> Hi,
> 
> in GuiToolbar.h we include strfwd.h, clearly because
> we use std::string there (as introduced by Riki in
> cc4bfc7f04d).
> 
> However in many different .h files we include <string>
> for the same purpouse. I suspect we should be consistent
> but I am not sure what is correct.
> 
> Is the only purpose of strfwd to avoid lengthy standard
> string/stream headers? If so should we replace <string>
> includes in rest of headers by strfwd?

I think it was part of André's work to reduce compilation times. 
However, I am not sure that strfwd.h is always useful these days:

// For gcc5 with the new std::string ABI forward declarations would work in
// principle, but I am not sure whether we want non-standard
// "namespace __cxx11" in our sources.
#if defined(USE_LLVM_LIBCPP) || defined(USE_GLIBCXX_CXX11_ABI)
#include <string>
#else


Basically, for gcc >=5 and libc++, we include <string>. Unless there is 
something I do not understand, the header is not really useful IMO.

It might be though that it makes a difference with cygwin or msvc.

JMarc



More information about the lyx-devel mailing list