2013年3月17日星期日

u_int32_t vs uint32_t


iOS官网文档里面 都用的 uint32_t

uint32_t 是在 usr/include/stdint.h 头文件定义

u_int32_t 是在 usr/include/i386/types.h 头文件定义的


We need to explain how the typedefs "u_int32_t" vs "uint32_t" conform to 
various standards in ANSI or ISO.
I do not have access to the OpenBSD files, but include the relevent statements from Solaris:


Excerpted from  on Solaris 10:

#pragma ident   "@(#)int_types.h        1.9     04/06/14 SMI"

/*
 * This file, , is part of the Sun Microsystems 
implementation
 * of  defined in the ISO C standard, ISO/IEC 9899:1999
 * Programming language - C.
 *
 * Programs/Modules should not directly include this file.  Access to the
 * types defined in this file should be through the inclusion of one of the
 * following files:
 *
 *                 Provides only the "_t" types defined in this
 *                              file which is a subset of the contents of
 *                              .  (This can be appropriate for
 *                              all programs/modules except those claiming
 *                              ANSI-C conformance.)
 *
 *              Provides the Kernel and Driver appropriate
 *                              components of .
 *
 *                  For use by applications.
 *
 * See these files for more details.
 */

#include 
#include 

#ifdef __cplusplus
extern "C" {
#endif

/*
 * Basic / Extended integer types
 *
 * The following defines the basic fixed-size integer types.
 *
 * Implementations are free to typedef them to Standard C integer types or
 * extensions that they support. If an implementation does not support one
 * of the particular integer data types below, then it should not define the
 * typedefs and macros corresponding to that data type.  Note that int8_t
 * is not defined in -Xs mode on ISAs for which the ABI specifies "char"
 * as an unsigned entity because there is no way to define an eight bit
 * signed integral.
 */
#if defined(_CHAR_IS_SIGNED)
typedef char                    int8_t;
#else
#if defined(__STDC__)
typedef signed char             int8_t;
#endif
#endif
typedef short                   int16_t;
typedef int                     int32_t;
#ifdef  _LP64
#define _INT64_TYPE
typedef long                    int64_t;
#else   /* _ILP32 */
#if defined(_LONGLONG_TYPE)
#define _INT64_TYPE
typedef long long               int64_t;
#endif
#endif

typedef unsigned char           uint8_t;
typedef unsigned short          uint16_t;
typedef unsigned int            uint32_t;
#ifdef  _LP64
typedef unsigned long           uint64_t;
#else   /* _ILP32 */
#if defined(_LONGLONG_TYPE)
typedef unsigned long long      uint64_t;
#endif
#endif

没有评论:

发表评论