• Kirill Smelkov's avatar
    libgolang: Use custom list_entry on MSVC · 715fa60b
    Kirill Smelkov authored
    list_entry, as provided by linux/list.h, uses statement expressions(*) which
    are not supported by MSVC:
    
        #define list_entry(ptr, type, member) ({              \
                const typeof( ((type *)0)->member ) *__mptr = (ptr);   \
                (type *)( (char *)__mptr - offsetof(type,member) );})
    
        golang/runtime/libgolang.cpp(439): error C2059: syntax error: '{'
        golang/runtime/libgolang.cpp(439): error C2143: syntax error: missing ';' before '{'
        golang/runtime/libgolang.cpp(439): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
        golang/runtime/libgolang.cpp(439): error C2440: 'initializing': cannot convert from 'list_head' to 'int'
        golang/runtime/libgolang.cpp(439): note: No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
        golang/runtime/libgolang.cpp(439): error C2143: syntax error: missing ';' before '*'
        golang/runtime/libgolang.cpp(439): error C2065: '__mptr': undeclared identifier
        golang/runtime/libgolang.cpp(439): error C2059: syntax error: ')'
    
    -> work it around by defining list_entry with C++ lambda.
    
    (*) https://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html
    715fa60b
libgolang.cpp 36.6 KB