diff --git a/include/boost/endian/buffers.hpp b/include/boost/endian/buffers.hpp index f8eb342..f87ddef 100644 --- a/include/boost/endian/buffers.hpp +++ b/include/boost/endian/buffers.hpp @@ -218,7 +218,9 @@ namespace endian template< BOOST_SCOPED_ENUM(order) Order, class T, std::size_t n_bits > class endian_buffer { -private: +#ifdef BOOST_ENDIAN_NO_CTORS +public: +#endif BOOST_STATIC_ASSERT( (n_bits/8)*8 == n_bits ); diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index cde5d12..3598ae0 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -108,3 +108,5 @@ run-ni endian_reverse_test4.cpp ; run endian_reverse_test5.cpp ; run-ni endian_reverse_test5.cpp ; + +run packed_buffer_test.cpp ; diff --git a/test/packed_buffer_test.cpp b/test/packed_buffer_test.cpp new file mode 100644 index 0000000..d3551f2 --- /dev/null +++ b/test/packed_buffer_test.cpp @@ -0,0 +1,33 @@ +// Copyright 2020 Peter Dimov +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt + +#if !defined(__GNUC__) + +#include +BOOST_PRAGMA_MESSAGE( "Skipping test because __GNUC__ is not defined" ) +int main() {} + +#else + +#define BOOST_ENDIAN_FORCE_PODNESS +#define BOOST_ENDIAN_NO_CTORS +#include +#include + +using namespace boost::endian; + +struct X +{ + big_uint16_buf_t a; + double b; + little_uint16_buf_t c; +} __attribute__((packed)); + +int main() +{ + BOOST_TEST_EQ( sizeof( X ), 12 ); + return boost::report_errors(); +} + +#endif