> MM> On 2001.07.01 12:26 Manuel McLure wrote: > >> I found the following issue when trying to compile CVS avi-xmms with CVS > >> avifile. In avifile's default.h the following construct is found: > >> > >> #ifdef HAVE_STDINT_H > >> #include <stdint.h> // for int64_t (on linux) > >> #else > >> #ifdef HAVE_SYS_TYPES_H > >> #include <sys/types.h> // for int64_t (on xBSD/solaris) > >> #endif > >> #endif Attached is a header file from intel that tries to address this problem in a standard way. I'm passing it along just as an additional perspective. It is available from: http://developer.intel.com/software/products/itc/architec/itanium/cc_mod/index.htm Multi-Platform Compilation -> Using the typcompat.h Include file
/* compatible.h */ #ifndef _COMPATIBILITY_H_ #define _COMPATIBILITY_H_ /* This #include file establishes definitions and macros aiding cross- * platform (Windows, UNIX) portable source code and allows applications * to scale their capabilities and capacities when compiled on 64-bit OSes, * while preserving their 32-bit capacities when compiled on 32-bit OSes. * This is accomplished using: * - size-specifc and scalable data type names that can be used across * platforms * - macros suitable for compile-time adjustments of: * - printf() formatting * - sized numeric constants * By #include'ing this file, source code: * - can be written with size-specific and purpose-specific data types * which aid the reader and maintainer * - continue to use OS-specifc types, as required by certain APIs or * other #include files specified by source code * * The types which become useful by inclusion of this file are: * type name purpose * ---------- Types used for integer / counted data: * int8_t 8-bit signed integer * uint8_t 8-bit UNsigned integer * int16_t 16-bit signed integer * uint16_t 16-bit UNsigned integer * int32_t 32-bit signed integer * uint32_t 32-bit UNsigned integer * int64_t 64-bit signed integer * uint64_t 64-bit UNsigned integer * ---------- Types used ONLY for an integer-ized pointer: * intptr_t pointer-sized signed integer, as in offset calculations * uintptr_t pointer-sized UNsigned integer * ---------- Types which scale in size with machine architecture: * int3264_t signed integer approp. for s/w built on "this" architecture * uint3264_t signed integer approp. for s/w built on "this" architecture * * The majority of these types are inspired by the UNIX/98 standard, as they: * - are more concise in their unsigned form than the sized type of the * Microsoft environment (which need the "unsigned" keyword) * - avoid int-size sensitivity problems documented by MSFT when VC++ * compiles the __int8, __int16, ... types * - avoids __int3264 type recommended against by MSFT * * Declarations of scaled-size constants are enabled by using the * CONST3264() * macro. * * */ #include <limits.h> #if defined(_WIN32) #if (_MSC_VER > 1000) #pragma once #endif /* separately #include <basetsd.h> if you want MSFT's sized types also */ typedef signed char int8_t; typedef unsigned char uint8_t; typedef signed short int16_t; typedef unsigned short uint16_t; typedef signed int int32_t; typedef unsigned int uint32_t; typedef signed __int64 int64_t; typedef unsigned __int64 uint64_t; #if !defined(_WIN64) /* features and definitions specific to 32-bit architecture compiles */ typedef int32_t int3264_t; typedef uint32_t uint3264_t; const uint3264_t UI3264_MAX= _UI32_MAX; const int3264_t I3264_MIN= _I32_MIN; const int3264_t I3264_MAX= _I32_MAX; /* the following #defines match macros laid down by some AWK scripts */ #define CONST3264(a) (a##L) #define UCONST3264(a) (a##UL) #define FMT3264 "l" #else /* is _WIN64 */ /* features and definitions specific to 64-bit architecture compiles */ typedef signed __int64 int3264_t; typedef unsigned __int64 uint3264_t; const uint3264_t UI3264_MAX= _UI64_MAX; const int3264_t I3264_MIN= _I64_MIN; const int3264_t I3264_MAX= _I64_MAX; /* the following #defines match macros laid down by some AWK scripts */ #define CONST3264(a) (a##i64) #define UCONST3264(a) (a##Ui64) #define FMT3264 "I64" #endif /* _WIN64 */ #elif defined(__unix) || defined(unix) #if (_XOPEN_SOURCE - 0 >= 500) /* UNIX/98 or newer */ #include <inttypes.h> #else /* UNIX/95, Spec1170, XPG/3 or older */ typedef signed char int8_t; typedef unsigned char uint8_t; typedef signed short int16_t; typedef unsigned short uint16_t; typedef signed int int32_t; typedef unsigned int uint32_t; #endif /* long-related types & features scale correctly from 32- to 64-bit compiles */ typedef signed long int3264_t; typedef unsigned long uint3264_t; const uint3264_t UI3264_MAX= LONG_MAX; const int3264_t I3264_MIN= LONG_MIN; const int3264_t I3264_MAX= LONG_MAX; /* the following #defines match macros laid down by some AWK scripts */ #define CONST3264(a) (a##L) #define UCONST3264(a) (a##UL) #define FMT3264 "l" #if defined(_LP64)/*Solaris*/ || defined(__LP64__)/*HP-UX*/ /* any of several 64-bit UNIXes */ typedef long int64_t; typedef unsigned long uint64_t; #elif defined(__sun) || defined(__LL_MODE_)/*HP-UX*/ /* 32-bit UNIX that understands "long long" */ typedef long long int64_t; typedef unsigned long long uint64_t; #else #error Unknown how this UNIX handles 64-bit types (if at all) #endif #else /* something besides Windows or known UNIX OSes... */ #error Unhandled OS variant; please update <compatible.h> #endif /* What OS family? */ #endif /* _COMPATIBILITY_H_ */
