1// Copyright 2020 Peter Dimov
2// Distributed under the Boost Software License, Version 1.0.
3// https://www.boost.org/LICENSE_1_0.txt
4
5#if !defined(__GNUC__)
6
7#include <boost/config/pragma_message.hpp>
8BOOST_PRAGMA_MESSAGE( "Skipping test because __GNUC__ is not defined" )
9int main() {}
10
11#else
12
13#define BOOST_ENDIAN_FORCE_PODNESS
14#define BOOST_ENDIAN_NO_CTORS
15#include <boost/endian/buffers.hpp>
16#include <boost/core/lightweight_test.hpp>
17
18using namespace boost::endian;
19
20struct X
21{
22 big_uint16_buf_t a;
23 native_float64_buf_t b;
24 little_uint16_buf_t c;
25} __attribute__((packed));
26
27int main()
28{
29 BOOST_TEST_EQ( sizeof(big_uint16_buf_t), 2 );
30 BOOST_TEST_EQ( sizeof(native_float64_buf_t), 8 );
31 BOOST_TEST_EQ( sizeof(little_uint16_buf_t), 2 );
32
33 BOOST_TEST_EQ( sizeof(X), 12 );
34
35 return boost::report_errors();
36}
37
38#endif
39

source code of boost/libs/endian/test/packed_buffer_test.cpp