3 ms·
> For example, every example in Kernighan & Ritchie: "The C Programming Language (2nd Edition)" is also a C++ program. " That is rather dated, they do things l
by josefx 2y ago
> For example, every example in Kernighan & Ritchie: "The C Programming Language (2nd Edition)" is also a C++ program. "
That is rather dated, they do things like explicitly cast the void* pointer returned by malloc, but point out in the appendix that ANSI C dropped the cast requirement for pointer conversions involving void, C++ does not allow implicit void conversions to this day.
- pjmlp 2y ago> Well written C tends to be legal C++ also The "well written" remark is relevant. Many style guides will consider implicit void conversions not well written C. Naturally we are now on C23, and almost every C developer considers language extensions as being C, so whatever.
- deleted 2y ago[deleted]
- uecker 2y agoWell written idiomatic C is certainly not valid C++.
- pjmlp 2y agoDepends on the beholder, however it hardly matters on the days of C23, as mentioned.
- josefx 2y ago> The "well written" remark is relevant. So using casts that hid implicit int declarations for years is "well written"? > Many style guides will consider implicit void conversions not well written C. I could not find a "Many" guide, Linux Kernel and ffmpeg seem to advocate against pointless casts. > Naturally we are now on C23, So irrelevant to the creation time of ffmpeg and only applicable to intentionally non portable libraries.