C AMQP Protocol Engine API  0.5
proton/type_compat.h
Go to the documentation of this file.
00001 #ifndef PROTON_TYPE_COMPAT_H
00002 #define PROTON_TYPE_COMPAT_H 1
00003 
00004 /*
00005  *
00006  * Licensed to the Apache Software Foundation (ASF) under one
00007  * or more contributor license agreements.  See the NOTICE file
00008  * distributed with this work for additional information
00009  * regarding copyright ownership.  The ASF licenses this file
00010  * to you under the Apache License, Version 2.0 (the
00011  * "License"); you may not use this file except in compliance
00012  * with the License.  You may obtain a copy of the License at
00013  *
00014  *   http://www.apache.org/licenses/LICENSE-2.0
00015  *
00016  * Unless required by applicable law or agreed to in writing,
00017  * software distributed under the License is distributed on an
00018  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
00019  * KIND, either express or implied.  See the License for the
00020  * specific language governing permissions and limitations
00021  * under the License.
00022  *
00023  */
00024 
00025 /*
00026  * Handle special cases for stdint.h and the definition for ssize_t.
00027  * Third party libraries (e.g. Boost) may provide competing solutions.
00028  *
00029  * The effects of this include file may be controlled by overrides:
00030  *  PN_DEFINE_STDINT/PN_NODEFINE_STDINT   : turn on/off definition of int64_t etc.
00031  *  PN_DEFINE_SSIZE_T/PN_NODEFINE_SSIZE_T : turn on/off definition of ssize_t
00032  *  PN_INCLUDE_STDINT/PN_NOINCLUDE_STDINT : include (or not) stdint.h
00033  */
00034 
00035 // Honor positive overrides
00036 #if defined(PN_DEFINE_STDINT)
00037 #define PNI_DEFINE_STDINT
00038 #endif
00039 #if defined(PN_INCLUDE_STDINT)
00040 #define PNI_INCLUDE_STDINT)
00041 #endif
00042 #if defined(PN_DEFINE_SSIZE_T)
00043 #define PNI_DEFINE_SSIZE_T
00044 #endif
00045 
00046 // Determinine default action
00047 #ifndef _MSC_VER
00048 // Not Windows and not using Visual Studio
00049 #ifndef PNI_INCLUDE_STDINT
00050 #define PNI_INCLUDE_STDINT
00051 #endif
00052 #else
00053 // all versions of Visual Studio
00054 #ifndef PNI_DEFINE_SSIZE_T
00055 // ssie_t def is needed, unless third party definition interferes, e.g. python/swig
00056 #ifndef Py_CONFIG_H
00057 #define PNI_DEFINE_SSIZE_T
00058 #endif
00059 #endif
00060 
00061 #if (_MSC_VER < 1600)
00062 // VS 2008 and earlier
00063 #ifndef PNI_DEFINE_STDINT
00064 #define PNI_DEFINE_STDINT
00065 #endif
00066 #else
00067 // VS 2010 and newer
00068 #ifndef PNI_INCLUDE_STDINT
00069 #define PNI_INCLUDE_STDINT
00070 #endif
00071 
00072 #endif // (_MSC_VER < 1600)
00073 #endif //_MSC_VER
00074 
00075 // Honor negative overrides
00076 #ifdef PN_NODEFINE_SSIZE_T
00077 #undef PNI_DEFINE_SSIZE_T
00078 #endif
00079 #ifdef PN_NODEFINE_STDINT
00080 #undef PNI_DEFINE_STDINT
00081 #endif
00082 #ifdef PN_NOINCLUDE_STDINT
00083 #undef PNI_INCLUDE_STDINT
00084 #endif
00085 
00086 #ifdef PNI_INCLUDE_STDINT
00087 #include <stdint.h>
00088 #endif
00089 
00090 #ifdef PNI_DEFINE_SSIZE_T
00091 #ifdef _MSC_VER
00092 #include <BaseTsd.h>
00093 typedef SSIZE_T ssize_t;
00094 #else
00095 #error ssize_t definition not kown
00096 #endif
00097 #endif // PNI_DEFINE_SSIZE_T
00098 
00099 #ifdef PNI_DEFINE_STDINT
00100 #ifdef _MSC_VER
00101 
00102 typedef signed __int8 int8_t;
00103 typedef signed __int16 int16_t;
00104 typedef signed __int32 int32_t;
00105 typedef signed __int64 int64_t;
00106 
00107 typedef unsigned __int8 uint8_t;
00108 typedef unsigned __int16 uint16_t;
00109 typedef unsigned __int32 uint32_t;
00110 typedef unsigned __int64 uint64_t;
00111 
00112 #else // _MSC_VER
00113 #error stdint.h definitions not kown
00114 #endif
00115 #endif // PNI_DEFINE_SSIZE_T
00116 
00117 #endif /* type_compat.h */