0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-07-05 01:58:35 +02:00

ircd::util: Add util to output the sizeof() something at compile time.

This produces an error which stops compilation, but the result of sizeof()
is given in the error message.
This commit is contained in:
Jason Volk 2016-09-06 09:50:59 -07:00
parent 8eeb6af31f
commit 7ae8449078

View file

@ -324,6 +324,19 @@ UNIT_LITERAL_LD( PB, val * 1000.0L * 1000.0L * 1000.0L * 1000.0L * 1000.0L
UNIT_LITERAL_LD( EB, val * 1000.0L * 1000.0L * 1000.0L * 1000.0L * 1000.0L * 1000.0L )
/* Output the sizeof a structure at compile time.
* This stops the compiler with an error (good) containing the size of the target
* in the message.
*
* example: struct foo {}; IRCD_TEST_SIZEOF(foo)
*/
template<size_t SIZE>
struct _TEST_SIZEOF_;
#define IRCD_TEST_SIZEOF(name) \
ircd::util::_TEST_SIZEOF_<sizeof(name)> _test_;
} // namespace util
} // namespace ircd
#endif // __cplusplus