mirror of
https://github.com/systemd/systemd.git
synced 2026-08-09 17:38:42 +00:00
macro-fundamental: Introduce typeof_field()
This commit is contained in:
@@ -444,6 +444,7 @@ assert_cc(sizeof(dummy_t) == 0);
|
||||
#define DECLARE_SBAT(text)
|
||||
#endif
|
||||
|
||||
#define typeof_field(struct_type, member) typeof(((struct_type *) 0)->member)
|
||||
#define sizeof_field(struct_type, member) sizeof(((struct_type *) 0)->member)
|
||||
#define endoffsetof_field(struct_type, member) (offsetof(struct_type, member) + sizeof_field(struct_type, member))
|
||||
#define voffsetof(v, member) offsetof(typeof(v), member)
|
||||
|
||||
@@ -65,7 +65,7 @@ int main(void) {
|
||||
check_no_sign(ino_t, SIZEOF_INO_T);
|
||||
check_no_sign(rlim_t, SIZEOF_RLIM_T);
|
||||
check(time_t, SIZEOF_TIME_T);
|
||||
check(typeof(((struct timex *)0)->freq), SIZEOF_TIMEX_MEMBER);
|
||||
check(typeof_field(struct timex, freq), SIZEOF_TIMEX_MEMBER);
|
||||
|
||||
info_no_sign(typeof(function_pointer));
|
||||
info_no_sign(void*);
|
||||
|
||||
Reference in New Issue
Block a user