mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-04 04:50:30 +01:00
shared: make NM_STRUCT_OFFSET_ENSURE_TYPE() work with arrays
Some compilers don't convert arrays as _Generic() type selectors to their pointer type. That means, for those compilers the generic type would be an array and not a pointer. Work around that by adding zero to the pointer/array argument. Also, I cannot get this to work with "clang-3.4.2-9.el7". Disable it for that compiler. The value of the generic check is anyway that it only needs to work with some compiler combinations. That will trigger a compilation failure and we can fix the implementation also for compilers that don't support the macro. See-also: http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1930.htm
This commit is contained in:
parent
b8b8ef7600
commit
45c9f3c39b
1 changed files with 2 additions and 2 deletions
|
|
@ -635,8 +635,8 @@ NM_G_ERROR_MSG (GError *error)
|
|||
#define _NM_ENSURE_TYPE_CONST(type, value) ((const type) (value))
|
||||
#endif
|
||||
|
||||
#if _NM_CC_SUPPORT_GENERIC
|
||||
#define NM_STRUCT_OFFSET_ENSURE_TYPE(type, container, field) (_Generic ((((container *) NULL)->field), \
|
||||
#if _NM_CC_SUPPORT_GENERIC && ( !defined (__clang__) || __clang_major__ > 3 )
|
||||
#define NM_STRUCT_OFFSET_ENSURE_TYPE(type, container, field) (_Generic ( (&(((container *) NULL)->field))[0] , \
|
||||
type: G_STRUCT_OFFSET (container, field)))
|
||||
#else
|
||||
#define NM_STRUCT_OFFSET_ENSURE_TYPE(type, container, field) G_STRUCT_OFFSET (container, field)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue