lua5.1のプラットフォーム間での互換性維持について(主に型のサイズについて)
参考
http://hammm.blog21.fc2.com/blog-entry-55.html
luaではconfig.hをつくって、そこでコンパイル時にちゃんとサイズが決まるようになってる
VMのインストラクションのサイズを追っていくと
llimints.h
http://www.lua.org/source/5.1/llimits.h.html
typedef LUAI_UINT32 lu_int32; /* ** type for virtual-machine instructions ** must be an unsigned with (at least) 4 bytes (see details in lopcodes.h) */ typedef lu_int32 Instruction;
http://www.lua.org/source/5.1/luaconf.h.html
luaconf.h
/* @@ LUAI_UINT32 is an unsigned integer with at least 32 bits. @@ LUAI_INT32 is an signed integer with at least 32 bits. @@ LUAI_UMEM is an unsigned integer big enough to count the total @* memory used by Lua. @@ LUAI_MEM is a signed integer big enough to count the total memory @* used by Lua. ** CHANGE here if for some weird reason the default definitions are not ** good enough for your machine. (The definitions in the 'else' ** part always works, but may waste space on machines with 64-bit ** longs.) Probably you do not need to change this. */ #if LUAI_BITSINT >= 32 #define LUAI_UINT32 unsigned int #define LUAI_INT32 int #define LUAI_MAXINT32 INT_MAX #define LUAI_UMEM size_t #define LUAI_MEM ptrdiff_t #else /* 16-bit ints */ #define LUAI_UINT32 unsigned long #define LUAI_INT32 long #define LUAI_MAXINT32 LONG_MAX #define LUAI_UMEM unsigned long #define LUAI_MEM long #endif
素直にinttype.h使えばいいのにと思ったら、これはC99からだったのね。luaは互換性の点からC89にこだわってるって聞いてるし。
おまけ:inttype.h C99関連でググったら見つけたんだけど
C1Xだと・・・・・・C++0x厨顔真っ赤wwwwww俺大勝利wwwwww
http://en.wikipedia.org/wiki/C1X