On 01 May 2015, at 12:23, Mike McTernan (wavemobile) mike.mcternan@wavemobile.com wrote:
Yikes!
I think the definition of container_of() shouldn't cast ptr:
#define container_of(ptr, type, member) ({ \
const typeof( ((type *)0)->member ) *__mptr = (typeof( ((type *)0)->member ) *)(ptr); \
const typeof( ((type *)0)->member ) *__mptr = (ptr); \ (type *)( (char *)__mptr - offsetof(type, member) );})
In OpenBSC the cast was added in be68f6fc6cde1367a4481d2e774a64e2cd657267
Change the variable "new" to "_new" in order to include it from C++ code. The define "container_of" will cast pointer before assigning. Compilers with stricter options require this. (Andreas Eversberg)
I still think we should revert the cast and see how C++ code complains and then look at the compiler warning. As you were able to compile osmo-pcu (a C++ app that uses linked lists) it can’t be that bad.