Fix compilation warning in cmp_def.h
According to offsetof(3) type of its return value is size_t. Assigning result of offsetof() to a variable of type ptrdiff_t may result in compilation warnings on certain platforms: src/box/key_def.cc:57:2: error: non-constant-expression cannot be narrowed from type 'size_t' (aka 'unsigned long') to 'ptrdiff_t' (aka 'long') in initializer list [-Wc++11-narrowing] OPT_DEF_ENUM(PART_OPT_TYPE, field_type, struct key_part_def, type, ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/box/opt_def.h:76:19: note: expanded from macro 'OPT_DEF_ENUM' { key, OPT_ENUM, offsetof(opts, field), sizeof(int), #enum_name, \ ^~~~~~~~~~~~~~~~~~~~~ src/trivia/util.h:193:32: note: expanded from macro 'offsetof' #define offsetof(type, member) ((size_t) &((type *)0)->member) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Fix this by changing the type of opt_def::offset from ptrdiff_t to size_t. Closes #2930
Please register or sign in to comment