| [2] | 1 | The collector uses a large amount of conditional compilation in order to
|
|---|
| 2 | deal with platform dependencies. This violates a number of known coding
|
|---|
| 3 | standards. On the other hand, it seems to be the only practical way to
|
|---|
| 4 | support this many platforms without excessive code duplication.
|
|---|
| 5 |
|
|---|
| 6 | A few guidelines have mostly been followed in order to keep this manageable:
|
|---|
| 7 |
|
|---|
| 8 | 1) #if and #ifdef directives are properly indented whenever easily possible.
|
|---|
| 9 | All known C compilers allow whitespace between the "#" and the "if" to make
|
|---|
| 10 | this possible. ANSI C also allows white space before the "#", though we
|
|---|
| 11 | avoid that. It has the known disadvantages that it differs from the normal
|
|---|
| 12 | GNU conventions, and that it makes patches larger than otherwise necessary.
|
|---|
| 13 | In my opinion, it's still well worth it, for the same reason that we indent
|
|---|
| 14 | ordinary "if" statements.
|
|---|
| 15 |
|
|---|
| 16 | 2) Whenever possible, tests are performed on the macros defined in gcconfig.h
|
|---|
| 17 | instead of directly testing patform-specific predefined macros. This makes it
|
|---|
| 18 | relatively easy to adapt to new compilers with a different set of predefined
|
|---|
| 19 | macros. Currently these macros generally identify platforms instead of
|
|---|
| 20 | features. In many cases, this is a mistake.
|
|---|
| 21 |
|
|---|
| 22 | 3) The code currently avoids #elif, eventhough that would make it more
|
|---|
| 23 | readable. This was done since #elif would need to be understood by ALL
|
|---|
| 24 | compilers used to build the collector, and that hasn't always been the case.
|
|---|
| 25 | It makes sense to reconsider this decision at some point, since #elif has been
|
|---|
| 26 | standardized at least since 1989.
|
|---|
| 27 |
|
|---|
| 28 | Many of the tested configuration macros are at least somewhat defined in
|
|---|
| 29 | either include/private/gcconfig.h or in Makefile.direct. Here is an attempt
|
|---|
| 30 | at defining some of the remainder: (Thanks to Walter Bright for suggesting
|
|---|
| 31 | this. This is a work in progress)
|
|---|
| 32 |
|
|---|
| 33 | MACRO EXPLANATION
|
|---|
| 34 | ----- -----------
|
|---|
| 35 |
|
|---|
| 36 | __DMC__ Always #define'd by the Digital Mars compiler. Expands
|
|---|
| 37 | to the compiler version number in hex, i.e. 0x810 is
|
|---|
| 38 | version 8.1b0
|
|---|
| 39 |
|
|---|
| 40 | _ENABLE_ARRAYNEW
|
|---|
| |
|---|