pack.h (2064B)
1/** 2 * WinPR: Windows Portable Runtime 3 * Pragma Pack 4 * 5 * Copyright 2014 Marc-Andre Moreau <marcandre.moreau@gmail.com> 6 * 7 * Licensed under the Apache License, Version 2.0 (the "License"); 8 * you may not use this file except in compliance with the License. 9 * You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, software 14 * distributed under the License is distributed on an "AS IS" BASIS, 15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 * See the License for the specific language governing permissions and 17 * limitations under the License. 18 */ 19 20/** 21 * This header is meant to be repeatedly included 22 * after defining the operation to be done: 23 * 24 * #define WINPR_PACK_PUSH 25 * #include <winpr/pack.h> // enables packing 26 * 27 * #define WINPR_PACK_POP 28 * #include <winpr/pack.h> // disables packing 29 * 30 * On each include, WINPR_PACK_* macros are undefined. 31 */ 32 33#if !defined(__APPLE__) 34#ifndef WINPR_PRAGMA_PACK_EXT 35#define WINPR_PRAGMA_PACK_EXT 36#endif 37#endif 38 39#ifdef PRAGMA_PACK_PUSH 40#ifndef PRAGMA_PACK_PUSH1 41#define PRAGMA_PACK_PUSH1 42#endif 43#undef PRAGMA_PACK_PUSH 44#endif 45 46#ifdef PRAGMA_PACK_PUSH1 47#ifdef WINPR_PRAGMA_PACK_EXT 48#pragma pack(push, 1) 49#else 50#pragma pack(1) 51#endif 52#undef PRAGMA_PACK_PUSH1 53#endif 54 55#ifdef PRAGMA_PACK_PUSH2 56#ifdef WINPR_PRAGMA_PACK_EXT 57#pragma pack(push, 2) 58#else 59#pragma pack(2) 60#endif 61#undef PRAGMA_PACK_PUSH2 62#endif 63 64#ifdef PRAGMA_PACK_PUSH4 65#ifdef WINPR_PRAGMA_PACK_EXT 66#pragma pack(push, 4) 67#else 68#pragma pack(4) 69#endif 70#undef PRAGMA_PACK_PUSH4 71#endif 72 73#ifdef PRAGMA_PACK_PUSH8 74#ifdef WINPR_PRAGMA_PACK_EXT 75#pragma pack(push, 8) 76#else 77#pragma pack(8) 78#endif 79#undef PRAGMA_PACK_PUSH8 80#endif 81 82#ifdef PRAGMA_PACK_PUSH16 83#ifdef WINPR_PRAGMA_PACK_EXT 84#pragma pack(push, 16) 85#else 86#pragma pack(16) 87#endif 88#undef PRAGMA_PACK_PUSH16 89#endif 90 91#ifdef PRAGMA_PACK_POP 92#ifdef WINPR_PRAGMA_PACK_EXT 93#pragma pack(pop) 94#else 95#pragma pack() 96#endif 97#undef PRAGMA_PACK_POP 98#endif 99 100#undef WINPR_PRAGMA_PACK_EXT