From: Lorenzo Stoakes > Sent: 24 July 2024 09:45 .. > It seems that (again, all credit to Arnd for his thorough analysis here) a > lot of the underyling issue revolves around the macros need to function > both in scenarios where we absolutely must have a constant value (for > instance, array size) as well as in scenarios where this is not the case. > > Arnd also discovered [0] there _relatively_ few call sites that require > this, so maybe a way forward might be to create specific min()/max() macros > for the strictly const case and to fix up the core ones to reduce expansion > at the cost of not being able to use these in these scenarios? > > Does this seem viable? Perhaps David you might have thoughts on this? Indeed. MIN() and MAX() could be used for compile-time constants (and require constants). They would then be usable for static initialisers. Before that can be done all the places that locally define MIN() and MAX() need changing to either use min()/max() or surround the local definition with an #ifdef until the global definition is added. But there are some optimisations that can be done first. The significant one is implement min3() directly (and probably without the 'can be constant' logic. David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)