[Boost.TypeErasure] - Issue compiling under Windows with Embarcadero C++ Builder 11.3
Hi
I'm using the type erasure library but have an issue (which I can workaround) when compiling in Windows 10 using Embarcadero C++ Builder 11.3.
My problem is that C++ Builder brings in the Windows SDK Windows.h include file in every Windows VCL UI project it creates *before* any of my code has compiled and it's causing conflicts in boost header member11.hpp.
This code is enough to cause the error:
#include
::type;
and the compiler complains of conflicts.
Embarcadero support have told me that I can't prevent Windows.h being included in my project before my boost-using code is compiled and attempts I've made to circumvent the problem, such as adding these lines to codegear.hpp:
#ifdef interface
#undef interface
#endif
don't work because C++ Builder is still including Windows.h before my code is compiled.
To get around the problem, I changed member11.hpp in my boost installation to
template
::type;
which I don't think will have side effects as 'interface/interface_' here is self-contained, but it doesn't feel like a good long term solution. Embarcadero support said: "Boost brings windows.h in because boost pulls it, *IF* the application is compiled for multi-threading then boost needs to access the OS threading functions, this is when you compile *without* the VCL." and I have confirmed this by creating a simple, multi-threaded Windows console application in C++ Builder... My question is: Is there a better way to work around this issue? My tests indicate that the Type Erasure library is working properly with my change, but it feels more like a hack than a fix... Thanks, Andy Bell Control Systems & Software Engineer Tel: +44 (0)1903 891700 Fax: +44 (0)1903 893888 Web: www.thermcosystems.comhttp://www.thermcosystems.com/ www.csd-epi.comhttp://www.csd-epi.com/ [cid:image002.png@01D9ADAA.693C8600] [Logo, company name Description automatically generated] P Please consider the environment before printing this email. This email and any files transmitted with it are confidential and intended solely for the intended recipient. If you are not the named addressee you should not disseminate, distribute, copy or alter this email. Any views or opinions presented in this email are solely those of the author and might not represent those of Tetreon Technologies Limited. Warning: Although Tetreon Technologies Limited has taken reasonable precautions to ensure no viruses are present in this email, the company cannot accept responsibility for any loss or damage arising from the use of this email or attachments. Tetreon Technologies Ltd is a limited company registered in England and Wales. Company Registration No. 4966845 Registered Offices: Highfield, Rock Road, Washington, West Sussex, RH20 3BH, England
El 03/07/2023 a las 14:01, Andy Bell via Boost-users escribió:
Hi
I’m using the type erasure library but have an issue (which I can workaround) when compiling in Windows 10 using Embarcadero C++ Builder 11.3.
My problem is that C++ Builder brings in the Windows SDK Windows.h include file in every Windows VCL UI project it creates **before** any of my code has compiled and it’s causing conflicts in boost header member11.hpp.
This code is enough to cause the error:
#include
#include
#include
#include
#include
#include
#include
namespace mynamespace {
BOOST_TYPE_ERASURE_MEMBER(ReadStatus)
}
The error is because Windows.h defines ‘interface’ but this code from member11.hpp also uses ‘interface’:
|template<|class|P, template<|class|...> |class|*interface*, |class||Sig|, |class||Concept|, |class||Base|, |class||ID|>| |using choose_member_interface = typename |::boost::mpl::if_c<||::boost::is_reference<P>::value|,| | typename |::boost::mpl::if_c<||::boost::type_erasure::detail::is_non_const_ref<P>::value|,| |*interface*
,| | Base| | >|::type|,| |*interface* | |>|::type|;| and the compiler complains of conflicts.
Hi Andy, The solution you propose (renaming "interface" as "interface_") looks perfectly fine to me, as template parameter names are not externally visible. In any case, would you mind filing an issue at https://github.com/boostorg/type_erasure/issues ? I may see that it's addressed. Best, Joaquín M López Muñoz
participants (2)
-
Andy Bell
-
Joaquin M López Muñoz