diff options
author | Simon Howard | 2007-06-21 11:32:04 +0000 |
---|---|---|
committer | Simon Howard | 2007-06-21 11:32:04 +0000 |
commit | ee2a6fda9fd817c191d74d0f1a00a4c05b4ed433 (patch) | |
tree | 7bcfdbd7969e12248887e026843576debdb28189 /HACKING | |
parent | bec32345ba1b4a32497d23af18e09c15b5e812f8 (diff) | |
download | chocolate-doom-ee2a6fda9fd817c191d74d0f1a00a4c05b4ed433.tar.gz chocolate-doom-ee2a6fda9fd817c191d74d0f1a00a4c05b4ed433.tar.bz2 chocolate-doom-ee2a6fda9fd817c191d74d0f1a00a4c05b4ed433.zip |
Add portability section to HACKING file.
Subversion-branch: /trunk/chocolate-doom
Subversion-revision: 921
Diffstat (limited to 'HACKING')
-rw-r--r-- | HACKING | 31 |
1 files changed, 31 insertions, 0 deletions
@@ -113,6 +113,37 @@ void FunctionName(int argument, int arg2, int arg3, int arg4, int arg5, } while (condition); } +Portability +=========== + +Chocolate Doom is designed to be cross-platform and work on different +Operating Systems and processors. Bear this in mind when writing code. + +Do not use the long type (its size differs across platforms; use +int or int64_t depending on which you want). + +Use Doom's byte data type for byte data. 'int' is assumed to be a +32-bit integer, and 'short' is a 16-bit integer. You can also use the +ISO C99 data types: intN_t and uintN_t where N is 8,16,32,64. + +Be careful with platform dependencies: do not use Windows API +functions, for example. Use SDL where possible. + +Preprocessor #defines are set that can be used to identify the OS +if necessary: _WIN32 for Windows and __MACOSX__ for MacOS X. Others +are set through SDL. Try to avoid this if possible. + +Be careful of endianness! Doom has SHORT() and LONG() macros that +do endianness conversion. Never assume that integer types have a +particular byte ordering. Similarly, never assume that fields +inside a structure are aligned in a particular way. This is most +relevant when reading or writing data to a file or a network pipe. + +For signed integers, you shouldn't assume that (i >> n) is the same as +(i / (1 << n)). However, most processors handle bitshifts of signed +integers properly, so it's not a huge problem. + + GNU GPL and licensing ===================== |