forbidden?  unnecessary?  (was: variable-length struct hack)
    Doug Gwyn 
    gwyn at smoke.BRL.MIL
       
    Sat Dec  9 19:57:32 AEST 1989
    
    
  
In article <4749 at fireball.cs.vu.nl> maart at cs.vu.nl (Maarten Litmaath) writes:
>But couldn't an conforming implementation FORBID the (T *) cast?!
No, a conforming implementation is obliged to accept a strictly
conforming application.  It cannot impose its own additional
constraints beyond those spelled out in the Standard.
>	strcpy(p->name = (char *)p + sizeof(T), s);
>If this method is used, copying the struct pointed to by p won't have strange
>effects, as long as *p isn't free()d.  Regarding the struct dirent example
>I'd call that an improvement.
Hardly.  The declared object T does not contain all of the information;
the "name" data lies outside the T object.  This is as bad as the case
that Dennis objected to so far as its usability goes (apart from
linguistic correctness issues).
    
    
More information about the Comp.std.c
mailing list