libsbp  v2.4.7
common.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012 Swift Navigation Inc.
3  * Contact: Henry Hallam <henry@swift-nav.com>
4  * Fergus Noble <fergus@swift-nav.com>
5  *
6  * This source is subject to the license found in the file 'LICENSE' which must
7  * be be distributed together with this source. All other rights reserved.
8  *
9  * THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
10  * EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
11  * WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
12  */
13 
14 #ifndef LIBSBP_COMMON_H
15 #define LIBSBP_COMMON_H
16 
17 #include <stdint.h>
18 #include <stdbool.h>
19 #include <inttypes.h>
20 
21 /* Should match guard in libswiftnav/common.h */
22 #ifndef COMMON_INT_TYPES
23 #define COMMON_INT_TYPES
24 
32 typedef int8_t s8;
34 typedef int16_t s16;
36 typedef int32_t s32;
38 typedef int64_t s64;
40 typedef uint8_t u8;
42 typedef uint16_t u16;
44 typedef uint32_t u32;
46 typedef uint64_t u64;
47 
48 #endif
49 
50 /* Set packing based upon toolchain */
51 #if defined(__GNUC__) || defined(__clang__)
52 
53 #define SBP_PACK_START /* Intentionally empty */
54 #define SBP_PACK_END /* Intentionally empty */
55 #define SBP_ATTR_PACKED __attribute__((packed))
56 
57 #elif defined(_MSC_VER)
58 
59 #define SBP_PACK_START __pragma(pack(1));
60 #define SBP_PACK_END __pragma(pack());
61 #define SBP_ATTR_PACKED /* Intentionally empty */
62 
63 #else
64 
65 #if !defined(SBP_PACK_START) || !defined(SBP_PACK_END) || !defined(SBP_ATTR_PACKED)
66 #error Unknown compiler, please override SBP_PACK_START, SBP_PACK_END, and SBP_ATTR_PACKED
67 #endif
68 
69 #endif /* toolchaing packing macros */
70 
73 #endif /* LIBSBP_COMMON_H */
74 
int8_t s8
Signed 8-bit integer.
Definition: common.h:32
int16_t s16
Signed 16-bit integer.
Definition: common.h:34
int64_t s64
Signed 64-bit integer.
Definition: common.h:38
uint8_t u8
Unsigned 8-bit integer.
Definition: common.h:40
uint64_t u64
Unsigned 64-bit integer.
Definition: common.h:46
uint16_t u16
Unsigned 16-bit integer.
Definition: common.h:42
uint32_t u32
Unsigned 32-bit integer.
Definition: common.h:44
int32_t s32
Signed 32-bit integer.
Definition: common.h:36