C AMQP Protocol Engine API  0.7
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
type_compat.h
Go to the documentation of this file.
1 #ifndef PROTON_TYPE_COMPAT_H
2 #define PROTON_TYPE_COMPAT_H 1
3 
4 /*
5  *
6  * Licensed to the Apache Software Foundation (ASF) under one
7  * or more contributor license agreements. See the NOTICE file
8  * distributed with this work for additional information
9  * regarding copyright ownership. The ASF licenses this file
10  * to you under the Apache License, Version 2.0 (the
11  * "License"); you may not use this file except in compliance
12  * with the License. You may obtain a copy of the License at
13  *
14  * http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing,
17  * software distributed under the License is distributed on an
18  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19  * KIND, either express or implied. See the License for the
20  * specific language governing permissions and limitations
21  * under the License.
22  *
23  */
24 
25 // Get Boolean
26 #if !defined(__cplusplus) && !defined(__bool_true_false_are_defined)
27 # if __STDC_VERSION__ >= 199901L || __GNUC__ >= 3 || _MSC_VER >=1800
28 # include <stdbool.h>
29 # else
30 // Need to get bool/true/false manually
31 # if _MSC_VER
32 # define bool char
33 # define false 0
34 # define true 1
35 # define __bool_true_false_are_defined
36 # else
37 # error "No definitions for bool/true/false"
38 # endif
39 # endif
40 #endif
41 /*
42  * Handle special cases for stdint.h and the definition for ssize_t.
43  * Third party libraries (e.g. Boost) may provide competing solutions.
44  *
45  * The effects of this include file may be controlled by overrides:
46  * PN_DEFINE_STDINT/PN_NODEFINE_STDINT : turn on/off definition of int64_t etc.
47  * PN_DEFINE_SSIZE_T/PN_NODEFINE_SSIZE_T : turn on/off definition of ssize_t
48  * PN_INCLUDE_STDINT/PN_NOINCLUDE_STDINT : include (or not) stdint.h
49  */
50 
51 // Honor positive overrides
52 #if defined(PN_DEFINE_STDINT)
53 # define PNI_DEFINE_STDINT
54 #endif
55 #if defined(PN_INCLUDE_STDINT)
56 # define PNI_INCLUDE_STDINT)
57 #endif
58 #if defined(PN_DEFINE_SSIZE_T)
59 # define PNI_DEFINE_SSIZE_T
60 #endif
61 
62 // Determinine default action
63 #ifndef _MSC_VER
64 // Not Windows and not using Visual Studio
65 # ifndef PNI_INCLUDE_STDINT
66 # define PNI_INCLUDE_STDINT
67 # endif
68 #else
69 // all versions of Visual Studio
70 # ifndef PNI_DEFINE_SSIZE_T
71 // ssize_t def is needed, unless third party definition interferes, e.g. python/swig
72 # ifndef Py_CONFIG_H
73 # define PNI_DEFINE_SSIZE_T
74 # endif
75 # endif
76 
77 # if (_MSC_VER < 1600)
78 // VS 2008 and earlier
79 # ifndef PNI_DEFINE_STDINT
80 # define PNI_DEFINE_STDINT
81 # endif
82 # else
83 // VS 2010 and newer
84 # ifndef PNI_INCLUDE_STDINT
85 # define PNI_INCLUDE_STDINT
86 # endif
87 
88 # endif // (_MSC_VER < 1600)
89 #endif //_MSC_VER
90 
91 // Honor negative overrides
92 #ifdef PN_NODEFINE_SSIZE_T
93 # undef PNI_DEFINE_SSIZE_T
94 #endif
95 #ifdef PN_NODEFINE_STDINT
96 # undef PNI_DEFINE_STDINT
97 #endif
98 #ifdef PN_NOINCLUDE_STDINT
99 # undef PNI_INCLUDE_STDINT
100 #endif
101 
102 #ifdef PNI_INCLUDE_STDINT
103 # include <stdint.h>
104 #endif
105 
106 #ifdef PNI_DEFINE_SSIZE_T
107 # ifdef _MSC_VER
108 # include <BaseTsd.h>
109 typedef SSIZE_T ssize_t;
110 # else
111 # error ssize_t definition not kown
112 # endif
113 #endif // PNI_DEFINE_SSIZE_T
114 
115 #ifdef PNI_DEFINE_STDINT
116 # ifdef _MSC_VER
117 
118 typedef signed __int8 int8_t;
119 typedef signed __int16 int16_t;
120 typedef signed __int32 int32_t;
121 typedef signed __int64 int64_t;
122 
123 typedef unsigned __int8 uint8_t;
124 typedef unsigned __int16 uint16_t;
125 typedef unsigned __int32 uint32_t;
126 typedef unsigned __int64 uint64_t;
127 
128 # else // _MSC_VER
129 # error stdint.h definitions not kown
130 # endif
131 #endif // PNI_DEFINE_SSIZE_T
132 
133 #endif /* type_compat.h */