diff --git a/BasiliskII/src/include/main.h b/BasiliskII/src/include/main.h index d886eb29..1ba7b6ac 100644 --- a/BasiliskII/src/include/main.h +++ b/BasiliskII/src/include/main.h @@ -74,4 +74,15 @@ extern uint32 InterruptFlags; // Currently pending interrupts extern void SetInterruptFlag(uint32 flag); // Set/clear interrupt flags extern void ClearInterruptFlag(uint32 flag); +// Array length +#if __cplusplus >= 201103L || (_MSC_VER >= 1900 && defined __cplusplus) +template +constexpr size_t lengthof(T (& a)[size]) +{ + return size; +} +#else +#define lengthof(a) (sizeof(a) / sizeof(a[0])) +#endif + #endif