6 ms·
As an aside, it's amusing that it took 25 years for C coders to embrace the C99 named struct designator feature: HttpParser parser = { .isValid = t
by yipikaya 11mo ago
As an aside, it's amusing that it took 25 years for C coders to embrace the C99 named struct designator feature:
HttpParser parser = {
.isValid = true,
.requestBuffer = strdup(request),
.requestLength = strlen(request),
.position = 0,
};
All the kids are doing it now!
- 1718627440 11mo agoThis is nice for constant data, but strdup can return NULL here, which is again never checked. > it took 25 years for C coders to embrace the C99 named struct designator feature Not sure if this actually true, but this is kind of the feature of C, 20 years old code or compiler is supposed to work just fine, so you just wait for some time to settle things. For fast and shiny, there is Javascript.
- davemp 11mo agoI’m still regularly getting on projects and moving C89 variable declarations from the start of functions to where they’re initialized, but I guess it’s not the kids doing it.
- mkfs 11mo ago> C89 variable declarations from the start of functions Technically it's the start of a block.
- davemp 11mo agoTechnically but I don’t think folks ever really bothered.
- 1718627440 11mo agoI only declare variables at the begin of a block, not because I would need C89 compatibility, but because I find it clearer to establish the working set of variables upfront. This doesn't restrict me in anyway, because I just start a new block, when I feel the need. I also try to keep the scope of a variable as small as possible.
- rurban 11mo agoIt's only Microsoft's fault to have not implemented it for decades in MSVC. They stayed at C89 forever.
- flykespice 11mo agoI never understand the reason why Microsoft lagged so much behind on newer c standards adoption. Did their compiler infrastructure made it difficult to adopt newer standards flexible? Or they simply did not care?
- rurban 11mo agoThey focused on C++ only. Management, not their devs.
- varjag 11mo agoSome of the most famous C codebases (e.g. the Linux kernel) been using them for some time.