zwol: stylized sketch of a face in profile (Default)
[personal profile] zwol

In C you can totally do this.

  typedef struct { ... } S;
  typedef struct { ...; S s; ... } T;

  /* ESS assumed to be contained in a T.  */
  T * TfromS(S * ess) {
    return (T *)(((char *)ess) - offsetof(T, s));
  }

But in C++, offsetof is not defined when its first argument is a “non-POD type” (approximately, “a type you couldn't have declared in C.”) The replacement for offsetof is the “pointer to member.”

But you can't do the above with a pointer to member.

So how the Belgium do you do it?

This account has disabled anonymous posting.
(will be screened if not validated)
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

April 2017

S M T W T F S
      1
2345678
9101112131415
16171819 202122
23242526272829
30      

Style Credit

Expand Cut Tags

No cut tags
Page generated Jan. 3rd, 2026 07:06 am
Powered by Dreamwidth Studios