[Mono-list] Preprocessor #define Standardization
Sun, 19 Aug 2001 02:47:29 +1000
On 18-Aug-2001, develop <email@example.com> wrote:
> I recommend we standardize on the usage of this directives in the class
> library now. And perhaps create a document listing the standard directives
> in use in the mono class library.
> The three definitions I have found are used in the PathTest.cs file, and
> meet my needs currently for base level OS directives, although I can
> certainly envision that derivatives will be needed as more subtle distro
> specific implementation issues are encountered.
> The three in use in PathTest.cs are:
I haven't looked at the code in PathTest.cs.
But as a matter of general principle...
Using conditional compilation which tests the OS is a bad idea, because
you never know when someone is going to invent a new platform that is a
mixture of previous different platforms. For example, a new platform
might be part SysV / part BSD (e.g. Linux), part Unix / part Windows
(e.g. Cygwin, Wine) or part Unix / part Mac (e.g. MacOS X). If the code
has conditionals which test directly on the OS, it makes it much more
difficult to port to new systems.
Instead, add an extra level of indirection, so the OS determines the
feature set and the code only ever tests for features, rather than
testing the OS. So rather than testing on WINDOWS in PathTest.cs,
test on e.g. WINDOWS_PATHNAMES.
Fergus Henderson <firstname.lastname@example.org> | "I have always known that the pursuit
The University of Melbourne | of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh> | -- the last words of T. S. Garp.