When I looked at the container_of macro definition in the Linux kernel, I saw the compound expression as a macro definition,
#define container_of(ptr, type, member) ({ \ const typeof( ((type *)0)->member ) *__mptr = (ptr); \ (type *)( (char *)__mptr - offsetof(type,member) );})
however, an unclear problem in my mind is which operator is taken into account as an rvalue. Apparently, the result of the last statement is used as an rvalue, but why?
(type *)( (char *)__mptr - offsetof(type,member) );
For example, the following code example in C?
int g_count = 0xFF; #define GLOBAL_COUNT do {g_count;} while(0) int main(int argc, char *argv[]) { int local; local = GLOBAL_COUNT; local = 0; GLOBAL_COUNT = local; return 0; }
What is a variable assignment rule in compound statements?
albin source share