mirror of
https://github.com/matrix-construct/construct
synced 2024-10-05 23:28:53 +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:
parent
8eeb6af31f
commit
7ae8449078
1 changed files with 13 additions and 0 deletions
|
@ -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 )
|
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 util
|
||||||
} // namespace ircd
|
} // namespace ircd
|
||||||
#endif // __cplusplus
|
#endif // __cplusplus
|
||||||
|
|
Loading…
Reference in a new issue