3 ms·
>But you can't do it in C. __typeof__ is a GNU extension. Yes you can. You just have to provide the type every time you use the macro yourself. You can even cr
by ainar-g 8y ago
>But you can't do it in C. __typeof__ is a GNU extension.
Yes you can. You just have to provide the type every time you use the macro yourself. You can even create a macro that creates helper “methods” for you.
With that said, I really dislike how common it is for C programmers to just use whatever their compiler's authors felt like adding and still calling it “portable C”. At this point, if you dislike “plain” C so much, you might as well just switch to a subset of C++ or D's “Better C” mode.
- ogoffart 8y agoYeah, i know you can even do it without providing the type: #define wl_container_of(ptr, sample, member) \ (void*)((char *)(ptr) + ((char*)(sample) - (char*)(&(sample)->member)))