[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#689932: Please define sized int{8,16,32,64}_t types portably even for GCC



Package: libc6-dev
Version: 2.13-35
Severity: wishlist
File: /usr/include/x86_64-linux-gnu/sys/types.h

sys/types.h defines the sized int types, such as int64_t, differently
for GCC than other compilers.  For non-GCC compilers, sys/types.h does
this:

typedef char int8_t;
typedef short int int16_t;
typedef int int32_t;
typedef long int int64_t;

However, for compilers that identify themselves as GCC (which includes
many non-GCC compilers), sys/types.h does this instead:

# define __intN_t(N, MODE) \
  typedef int int##N##_t __attribute__ ((__mode__ (MODE)))
sys/types.h defines the sized int types, such as int64_t, differently
for GCC than other compilers.  For non-GCC compilers, sys/types.h does
this:

typedef char int8_t;
typedef short int int16_t;
typedef int int32_t;
typedef long int int64_t;

However, for compilers that identify themselves as GCC (which includes
many non-GCC compilers), sys/types.h does this instead:

# define __intN_t(N, MODE) \
  typedef int int##N##_t __attribute__ ((__mode__ (MODE)))

__intN_t (8, __QI__);
__intN_t (16, __HI__);
__intN_t (32, __SI__);
__intN_t (64, __DI__);

These __mode__ attributes change the sizes of these types for GCC.  However, many
non-GCC compilers identify themselves as GCC because they support some
(but not all) extensions; such compilers will consider these types all
"int" if they don't recognize the __mode__ extension.

Do these GCC-specific declarations have some advantage over the portable
declarations?  If not, why not always use the portable declarations?

- Josh Triplett

-- System Information:
Debian Release: wheezy/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (1, 'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 3.2.0-3-amd64 (SMP w/4 CPU cores)
Locale: LANG=C.UTF-8, LC_CTYPE=C.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages libc6-dev:amd64 depends on:
ii  libc-dev-bin    2.13-35
ii  libc6           2.13-35
ii  linux-libc-dev  3.2.30-1

Versions of packages libc6-dev:amd64 recommends:
ii  gcc [c-compiler]      4:4.7.2-1
ii  gcc-4.6 [c-compiler]  4.6.3-11
ii  gcc-4.7 [c-compiler]  4.7.2-3

Versions of packages libc6-dev:amd64 suggests:
ii  glibc-doc     2.13-35
ii  manpages-dev  3.42-1

-- no debconf information


Reply to: