I found similar question Compile-time generic type size check, but it not received any answer.
The problem is in cooperation with other programming language via FFI + unsafe,
I want to be sure that mem::size_of::<*mut T>()
have suitable size.
I found such static_assert
macro in Internet:
macro_rules! static_assert {
(type $t:ty; ) => (
type __StaticAssert = $t;
);
(type $t:ty; $e:expr $(, $ee:expr)*) => (
static_assert!(type ($t, [i8; 0 - ((false == ($e)) as usize)]); $($ee),*);
);
($e:expr $(, $ee:expr)*) => (
static_assert!(type [i8; 0 - ((false == ($e)) as usize)]; $($ee),*);
);
}
static_assert!(2 == 2);
it works, but if I use mem::size_of::<*const f64>()
inside macro all fails,
because of: calls in constants are limited to struct and enum constructors
,
any idea how to calculate size_of
*const f64
at compile time?