7.3 Writing portable code

Free Pascal is designed to be cross-platform. This means that the basic RTL units are usable on all platforms, and the compiler behaves the same on all platforms (as far as possible). The Object Pascal langauge is the same on all platforms. Nevertheless, FPC comes with a lot of units that are not portable, but provide access to all possibilities that a platform provides.

The following are some guidelines to consider when writing portable code:

The system unit contains some constants which describe le access on a system:

LineEnding
A character or string which describes the end-of-line marker used on the current platform. Commonly, this is one of #10, #13#10 or #13.
LFNSupport
A boolean that indicates whether the system supports long lenames (i.e. is not limited to MS-DOS 8.3 lenames).
DirectorySeparator
is the character which acts as a separator between directory parts of a path.
DriveSeparator
for systems that supports driveletters, this is the character that is used to separate the drive indication from the path..
PathSeparator
the character used to separate items in a list (notably, a PATH).
maxExitCode
The maximum value for a process exitcode.
MaxPathLen
The maximum length of a lename, including a path.
FileNameCaseSensitive
a boolean that indicates whether lenames are handled case sensitively.
UnusedHandle
a value used to indicate an unused/invalid le handle.
StdInputHandle
the value of the standard input le handle. This is not always zero, as is commonly the case on Unices.
StdOutputHandle
the value of the standard input le handle. This is not always 1, as is commonly the case on Unices.
StdErrorHandle
the value of the standard input le handle. This is not always 2, as is commonly the case on Unices.
CtrlZMarksEOF
a boolean that indicates whether the #26 character marks the end of a le. (an old MS-DOS convention)