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 <boost/type_erasure/any.hpp>
#include <boost/type_erasure/any_cast.hpp>
#include <boost/type_erasure/builtin.hpp>
#include <boost/type_erasure/operators.hpp>
#include <boost/type_erasure/member.hpp>
#include <boost/type_erasure/free.hpp>
#include <boost/mpl/vector.hpp>
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<Sig, Concept, Base, const ID>,
Base
>::type,
interface<Sig, Concept, Base, ID>
>::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<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_<Sig, Concept, Base, const ID>,
Base
>::type,
interface_<Sig, Concept, Base, ID>
>::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.com<http://www.thermcosystems.com/>
www.csd-epi.com<http://www.csd-epi.com/>
[cid:[email protected]]
[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
_______________________________________________
Boost-users mailing list
[email protected]
https://lists.boost.org/mailman/listinfo.cgi/boost-users