Direct-BT  2.3.1
Direct-BT - Direct Bluetooth Programming.
packed_attribute.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2020 Gothel Software e.K.
3  * Copyright (c) 2020 ZAFENA AB
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining
6  * a copy of this software and associated documentation files (the
7  * "Software"), to deal in the Software without restriction, including
8  * without limitation the rights to use, copy, modify, merge, publish,
9  * distribute, sublicense, and/or sell copies of the Software, and to
10  * permit persons to whom the Software is furnished to do so, subject to
11  * the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be
14  * included in all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23  *
24  */
25 
26 #ifndef PACKED_ATTRIBUTE_HPP_
27 #define PACKED_ATTRIBUTE_HPP_
28 
29 /** packed__: lead in macro, requires __packed lead out as well. Consider using __pack(...). */
30 #ifndef packed__
31  #ifdef _MSC_VER
32  #define packed__ __pragma( pack(push, 1) )
33  #else
34  #define packed__
35  #endif
36 #endif
37 
38 /** __packed: lead out macro, requires packed__ lead in as well. Consider using __pack(...). */
39 #ifndef __packed
40  #ifdef _MSC_VER
41  #define __packed __pragma( pack(pop))
42  #else
43  #define __packed __attribute__ ((packed))
44  #endif
45 #endif
46 
47 /** __pack(...): Produces MSVC, clang and gcc compatible lead-in and -out macros. */
48 #ifndef __pack
49  #ifdef _MSC_VER
50  #define __pack(...) __pragma( pack(push, 1) ) __VA_ARGS__ __pragma( pack(pop))
51  #else
52  #define __pack(...) __VA_ARGS__ __attribute__ ((packed))
53  #endif
54 #endif
55 
56 #endif /* PACKED_ATTRIBUTE_HPP_ */