PortabilityHacks

DON'T USE C99 FEATURE!!!

DON'T USE GCC FEATURE!!!

types

long
don't forget LLP64
void *
LP32/LP64/LLP64
long long
use LONG_LONG or int64_t
codepoint
unsigned int

inttypes

  • int8_t
  • uint8_t
  • int16_t
  • uint16_t
  • int32_t
  • uint32_t
  • int64_t
  • uint64_t
  • intptr_t
  • uintptr_t
  • VALUE
  • SIGNED_VALUE

http://seclan.dll.jp/c99d/c99d09.htm#dt19990621

printf formats

  • PRId32
  • PRIdPTR
  • PRIdPTRDIFF
  • PRIdSIZE
  • PRIdVALUE

http://seclan.dll.jp/c99d/c99d09.htm#dt19990705

number conversion

NUM2INT have some intended strange behavior around overflows.

make

There are gmake, nmake, bsdmake, and so on.

iconv

There are glibc iconv, GNU libiconv, Citrus iconv, and so on.

special

You can use C99 feature and gcc feature when you treat other compilers.