kicad-developers team mailing list archive
-
kicad-developers team
-
Mailing list archive
-
Message #38989
Re: Boost namespace issues with unit tests
-
To:
kicad-developers@xxxxxxxxxxxxxxxxxxx
-
From:
jp charras <jp.charras@xxxxxxxxxx>
-
Date:
Sat, 12 Jan 2019 09:13:10 +0100
-
In-reply-to:
<CAG1r56+Cg1HB5-mtkhnmwE-K=8fHu_MY5-7DMmoD4RJxV1nWhA@mail.gmail.com>
-
Openpgp:
preference=signencrypt
-
User-agent:
Mozilla/5.0 (Windows NT 6.1; rv:60.0) Gecko/20100101 Thunderbird/60.4.0
Le 12/01/2019 à 02:14, John Beard a écrit :
> Hi,
>
> I have been alerted to some issues with the Boost-y unit tests. Nick
> has helped me get set up with an Ubuntu build in docker.
>
> I have tracked down the issues that caused compilation failures on old
> GCC versions. It is because GCC <7 does not support the following
> without at least an -fpermssive warning:
>
> template<> struct boost::test_tools::print_log_value<TYPE>
> {
> operator() (...){...}
> }
>
> Instead, you have to use the pre-C++11 namespace syntax:
>
> namespace boost {
> namespace test_tools {
> template<> struct print_log_value<TYPE>
> { ... }
> } }
>
> This would be OK, if verbose, but it is compounded by the problem that
> in Boost 1.58 (Ubuntu 16.04 LTS), the namespace is boost::test_tools
> and from 1.59, it is boost::test_tools:tt_detail. Having *either* two
> or three braced levels makes this hard to do without horrible macros.
>
> So, I propose to use the other way of printing in Boost tests: a free
> operator<<:
>
> std::ostream& operator<<( std::ostream& os, const Type& aThing )
> { ... }
>
> This is slightly crusty, in that it's putting a free operator<< out
> there that's not in the original library, but it is isolated and
> contained only in the test code.
>
>>From Boost 1.64, the customisation point boost_test_print_type is
> introduced, which allows to not clutter up the namespace with stray
> operator<< functions. Once we get to that minimum Boost version*, it's
> then a simple change over to:
>
> std::ostream& boost_test_print_type( std::ostream& os, const Type& aThing )
> { ... }
>
> Attached is a patch to implement free operator<< logging for the only
> problematic logger (for BOX2I). This is followed by the reversion of
> decc7ed88, which should no longer be required.
>
> I have checked this on GCC 8.2.1 and the Ubuntu build docker image.
> JP, could you check this works on whatever system threw the error for
> you?
>
> Cheers,
>
> John
>
> * Also, once min Boost is >=1.59, lots of other hackish macros to work
> around missing functions become superfluous, which will be nice!
> Notably, Ubuntu LTS 18.04 uses Boost 1.65.
>
Thanks, John,
Your fix works fine.
I tested it on W7 32bits (boost 1.63) and Linux Kubuntu 14.04 lts (boost
1.54)
I committed it.
--
Jean-Pierre CHARRAS
References