Structure inheritance and tail padding
Carlos Pita <[email protected]> Sat, 6 Feb 2016 11:25:39 -0300
| Newsgroups | gmane.comp.python.ctypes |
|---|---|
| Message-ID | <CAELgYhdQXyq0bYvFkC8-fQCvPTNozGEFh2hEpWFYtSO70u6_Mw@mail.gmail.com> |
Hi all,
just from observation I arrived to the unconfirmed conclusion that
Structure inheritance adds tail padding. For example:
class A(Structure):
_fields_ = [('a', c_double), ('b', c_char)]
class B(A):
_fields_ = [('c', c_int)]
will not show the same layout than:
class C(Structure):
_fields_ = [('a', c_double), ('b', c_char), ('c', c_int)]
Supposing my conclusion is right, what is the intention of this feature:
i. To support c++ pod subclassing? (most compilers reuse the tail
padding for non-pod subclassing).
ii. To support a more oo view of c struct composition? (btw, it
complements the ms-extensions very well).
Thank you in advance
--
Carlos
------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140