C AMQP Protocol Engine API  0.4
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros 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 /*
26  * Handle special cases for stdint.h and the definition for ssize_t.
27  * Third party libraries (e.g. Boost) may provide competing solutions.
28  *
29  * The effects of this include file may be controlled by overrides:
30  * PN_DEFINE_STDINT/PN_NODEFINE_STDINT : turn on/off definition of int64_t etc.
31  * PN_DEFINE_SSIZE_T/PN_NODEFINE_SSIZE_T : turn on/off definition of ssize_t
32  * PN_INCLUDE_STDINT/PN_NOINCLUDE_STDINT : include (or not) stdint.h
33  */
34 
35 // Honor positive overrides
36 #if defined(PN_DEFINE_STDINT)
37 #define PNI_DEFINE_STDINT
38 #endif
39 #if defined(PN_INCLUDE_STDINT)
40 #define PNI_INCLUDE_STDINT)
41 #endif
42 #if defined(PN_DEFINE_SSIZE_T)
43 #define PNI_DEFINE_SSIZE_T
44 #endif
45 
46 // Determinine default action
47 #ifndef _MSC_VER
48 // Not Windows and not using Visual Studio
49 #ifndef PNI_INCLUDE_STDINT
50 #define PNI_INCLUDE_STDINT
51 #endif
52 #else
53 // all versions of Visual Studio
54 #ifndef PNI_DEFINE_SSIZE_T
55 // ssie_t def is needed, unless third party definition interferes, e.g. python/swig
56 #ifndef Py_CONFIG_H
57 #define PNI_DEFINE_SSIZE_T
58 #endif
59 #endif
60 
61 #if (_MSC_VER < 1600)
62 // VS 2008 and earlier
63 #ifndef PNI_DEFINE_STDINT
64 #define PNI_DEFINE_STDINT
65 #endif
66 #else
67 // VS 2010 and newer
68 #ifndef PNI_INCLUDE_STDINT
69 #define PNI_INCLUDE_STDINT
70 #endif
71 
72 #endif // (_MSC_VER < 1600)
73 #endif //_MSC_VER
74 
75 // Honor negative overrides
76 #ifdef PN_NODEFINE_SSIZE_T
77 #undef PNI_DEFINE_SSIZE_T
78 #endif
79 #ifdef PN_NODEFINE_STDINT
80 #undef PNI_DEFINE_STDINT
81 #endif
82 #ifdef PN_NOINCLUDE_STDINT
83 #undef PNI_INCLUDE_STDINT
84 #endif
85 
86 #ifdef PNI_INCLUDE_STDINT
87 #include <stdint.h>
88 #endif
89 
90 #ifdef PNI_DEFINE_SSIZE_T
91 #ifdef _MSC_VER
92 #include <BaseTsd.h>
93 typedef SSIZE_T ssize_t;
94 #else
95 #error ssize_t definition not kown
96 #endif
97 #endif // PNI_DEFINE_SSIZE_T
98 
99 #ifdef PNI_DEFINE_STDINT
100 #ifdef _MSC_VER
101 
102 typedef signed __int8 int8_t;
103 typedef signed __int16 int16_t;
104 typedef signed __int32 int32_t;
105 typedef signed __int64 int64_t;
106 
107 typedef unsigned __int8 uint8_t;
108 typedef unsigned __int16 uint16_t;
109 typedef unsigned __int32 uint32_t;
110 typedef unsigned __int64 uint64_t;
111 
112 #else // _MSC_VER
113 #error stdint.h definitions not kown
114 #endif
115 #endif // PNI_DEFINE_SSIZE_T
116 
117 #endif /* type_compat.h */