[ovs-dev] [PATCH 4/5] Automatically verify that OVS header files work OK in C++ also.

Aaron Conole aconole at redhat.com
Tue Aug 1 14:32:56 UTC 2017


Ben Pfaff <blp at ovn.org> writes:

> On Mon, Jul 31, 2017 at 04:44:10PM -0400, Russell Bryant wrote:
>> On Mon, Jul 31, 2017 at 4:33 PM, Ben Pfaff <blp at ovn.org> wrote:
>> > On Mon, Jul 31, 2017 at 01:05:32PM -0700, Ben Pfaff wrote:
>> >> On Mon, Jul 31, 2017 at 03:50:59PM -0400, Russell Bryant wrote:
>> >> > On Sun, Jul 30, 2017 at 10:54 PM, Ben Pfaff <blp at ovn.org> wrote:
>> >> > > This should help address a recurring problem.
>> >> > >
>> >> > > Signed-off-by: Ben Pfaff <blp at ovn.org>
>> >> > > ---
>> >> > >  .travis.yml                     |  1 +
>> >> > >  Makefile.am                     |  1 +
>> >> > >  configure.ac                    |  2 ++
>> >> > >  include/openvswitch/automake.mk | 14 ++++++++++++++
>> >> > >  m4/openvswitch.m4               | 21 +++++++++++++++++++++
>> >> > >  5 files changed, 39 insertions(+)
>> >> >
>> >> > Why does this patch depend on libboost?  It looks like it's only used
>> >> > when building a test C++ program in configure.  We could build a test
>> >> > C++ program without the dependency, right?
>> >>
>> >> It's because of include/openvswitch/compiler.h, which has:
>> >>
>> >>     #elif defined(__cplusplus)
>> >>     #include <boost/static_assert.hpp>
>> >>     #define BUILD_ASSERT BOOST_STATIC_ASSERT
>> >>     #define BUILD_ASSERT_DECL BOOST_STATIC_ASSERT
>> >>
>> 
>> Ah, sorry ...
>> 
>> >> We could probably define our own C++-compatible static assert without
>> >> boost.  It looks like C++11 and later has a built-in static_assert:
>> >>     http://en.cppreference.com/w/cpp/language/static_assert
>> >>
>> >> Any idea whether it's reasonable to assume C++11 support these days?
>> 
>> I don't know, but that seems pretty reasonable to me.
>> 
>> I suppose if it becomes an issue, we could re-add the boost version as
>> an optional dependency that would get used only if C++11 wasn't
>> available?
>
> Sure.

It's actually quite reasonable to assume support for static_assert, it
was added to the working group during 2007/2008 timeframe, and every
compiler at the time which had c++-0x support (which I know includes
GCC[1], and VS[2]) have support for it.

Since this commit was applied I guess it doesn't matter, but it's
possibly useful information for the future.

>> Acked-by: Russell Bryant <russell at ovn.org>
>
> Thanks, I applied this whole series to master, using the revised version
> of this patch.
> _______________________________________________
> dev mailing list
> dev at openvswitch.org
> https://mail.openvswitch.org/mailman/listinfo/ovs-dev

[1]: https://gcc.gnu.org/gcc-4.3/cxx0x_status.html
[2]:
https://blogs.msdn.microsoft.com/vcblog/2008/10/28/lambdas-auto-and-static_assert-c0x-features-in-vc10-part-1/


More information about the dev mailing list