←back to thread

The C23 edition of Modern C

(gustedt.wordpress.com)
515 points bwidlar | 5 comments | | HN request time: 0.851s | source
Show context
johnisgood ◴[] No.41854897[source]
Personally this[1] just makes C much more complicated for me, and I choose C when I want simplicity. If I want complicated, I would just pick C++ which I typically would never want. I would just pick Go (or Elixir if I want a server).

"_BitInt(N)" is also ugly, reminds me of "_Bool" which is thankfully "bool" now.

[1] guard, defer, auto, constexpr, nullptr (what is wrong with NULL?), etc. On top of that "constexpr" and "nullptr" just reeks of C++.

That said, Modern C is an incredible book, I have been using it for C99 (which I intend to continue sticking to).

replies(10): >>41854987 #>>41855182 #>>41855214 #>>41855526 #>>41855553 #>>41856362 #>>41857239 #>>41859032 #>>41860073 #>>41935596 #
1. cornstalks ◴[] No.41854987[source]
> what is wrong with NULL?

For starters, you have to #include a header to use it.

replies(2): >>41855143 #>>41855812 #
2. zik ◴[] No.41855143[source]
And it avoids the NULL == 0 ambiguity, allowing for better type checking.
3. johnisgood ◴[] No.41855812[source]
Well, I always include stdio.h which includes stddef.h that defines NULL as (void *)0.
replies(1): >>41855960 #
4. dhhfss ◴[] No.41855960[source]
In my experience, hardly any source files require studio.h

stddef.h on the other hand is required by most to get size_t

replies(1): >>41859219 #
5. johnisgood ◴[] No.41859219{3}[source]
You are right. Hereby I correct my parent comment: I talked about my own personal experience[1], but yeah, as you said, stddef.h is often required (and yes, often I do not need stdio.h, stddef.h is what I need) which defines NULL, which was my point. If it is often required, then it does not matter whether you have to include a header file or not, IMO.

Just include the stddef.h header if you want to use NULL, similarly to how you include a header file if you want to use anything else, e.g. bool from stdbool.h.

[1] I am not entirely sure in retrospect, actually, as I might be misremembering, but my point stands with or without stdio.h!