News for hackers. Stuff that matters.
Re:Facil.io: A micro-framework for C web applications by jolmg on Saturday January 26, 2019 @11:17AM (#19006875)
That's really cool, but don't unassigned fields have undefined values? How would the function know what was set? I imagine that in practice they're almost always 0, but that's not guaranteed, right? You'd need to set the struct as {0}, to have everything be 0. Is this a feature of a new(ish) standard?
Re:Facil.io: A micro-framework for C web applications by hawski on Saturday January 26, 2019 @11:47AM (#19007033)
It is guaranteed per C99. It's a compound initializer.

Also if you set a struct with {1} the first field is set to 1 and the rest to 0. AFAIR it was always like that (at least since standardized C, but probably earlier).

Re:Facil.io: A micro-framework for C web applications by loeg on Saturday January 26, 2019 @12:25PM (#19007227)
C99 specifies that struct literals with absent fields are assigned a zero value. (Notably unspecified is the value of any implicit padding bytes in the struct.)