Sane API design (AKA C's #ifdef hell)
Kagamin
spam at here.lot
Fri Apr 24 07:40:42 UTC 2026
On Thursday, 16 April 2026 at 18:52:23 UTC, H. S. Teoh wrote:
> ```c
> // New version of the function, containing the ONLY actually
> necessary
> // #ifdef:
> int getMaxMacGuffin() {
> #ifdef BUILDING_FOR_NEW_PLATFORM
> return getMaxMacGuffinNewPlatform();
> #else
> return _getMaxMacGuffin();
> #endif
> }
> ```
This design pattern is called "platform abstraction layer".
More information about the Digitalmars-d
mailing list