- cross-platform, cross-Operating System, cross-compiler: . Eg, _x86_, _ppc_; PLATFORM_UNIX, Win32, _Win64, BIGENDIAN.
- preprocesser alternatives to #pragma once. Each of these would only occur once, at the top of a header file. These are the cases of :
... contents of header ...
- Extra debug-only checks. (_DEBUG, LOGGING)
- Toggling Features.
By far, most #defines were only used once (often as #pragma once alternatives).
|number of #defines||...that occured|
|6||100 to 1000 times|
|76||10 to 100 times|
|192||2 to 9 times|
|1242||1 time (mainly for #pragma once)|
I wonder how many other software projects have similar distributions. I think it's interesting to consider how these could be reduced.
#1 (cross-platform/OS, compiler) could certainly be reduced by programming at a higher abstraction level. Using C/C++ as a shortcut for assembly language tends to produce a lot of #ifdef usage like this.
#2 (#pragma once) is purely a consequence of the C preprocessor's design choices. Other languages (like C#) don't even have this.
#4 (Features) is ideally solved by better componentization and better design abstractions.
Here were the top usages: