Comparing D structs

Dan twinbee42 at skytopia.com
Sun May 17 15:14:06 PDT 2009


Jarrett Billingsley Wrote:

> On Sun, May 17, 2009 at 5:00 PM, Dan <twinbee42 at skytopia.com> wrote:
> > That sounds great, and seems like yet another reason for me to switch to D (other than the removal of header files which always seemed like a kludge).
> >
> > Just for the record though, I think one can initialize/blank/calloc C structs too, but the problem is that some struct elements (of the same array) may have padding while others don't, or perhaps they have different size paddings.
> 
> Sure, you can calloc or memset a C struct.  I've never heard of
> padding varying for different instances of the same struct type, but
> who knows.  So much of C is implementation-defined..

Perhaps I'm mistaken there. However, going through about 5-10 results on Google, it would seem there's no real solution in C to compare structs of the same type, because of whatever issues the padding thing may do. If it was as simple as memset/calloc, I'm sure that would've been mentioned.


More information about the Digitalmars-d-learn mailing list