Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Interesting C bits:

Name: Anonymous 2010-07-05 11:42

How offsetof is implemented(from wikipedia)
#define offsetof(st, m) \
    ((size_t) ( (char *)&((st *)(0))->m - (char *)0 ))

This works by casting a null pointer into a pointer to structure st, obtaining the address of member m within this structure, casting that address into a character pointer, then using pointer arithmetic to subtract the base address of the structure, all of which results in the number of character positions (i.e., bytes) between the beginning of the structure and the beginning of the member. The offsets evaluated will differ from compiler to compiler, and with build settings, but the calculations themselves are entirely portable.

Name: Anonymous 2010-07-05 16:24

>>6
Welcome to /prog/. Have a complimentary Xarn.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List