116
Why do libraries define their own true and false?
(pawb.social)
Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!
Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.
Hope you enjoy the instance!
Rules
Follow the wormhole through a path of communities !webdev@programming.dev
This is often done for backward compatibility, as stdbool.h which provides true and false wasn't standard before C99 and even though that's more than 25 years ago now a lot of old habits die hard.
Also, plenty of embedded systems don't use the C standard library.
stdbool.h (along with float.h, limits.h, stdarg.h, stddef.h, stdint.h, and some other library facilities) is required to be provided even in freestanding environment so, at least as long as you use an ISO C conformant compiler, you can always include those even if you don’t have a libc implementation
Yeah in the late 90's I was coding in C++ and I'm pretty sure I had to define true and false manually.
I seem to recall using the true and false literals C++ in the late '90s ... looks like they were in the C++98 standard, but it's not clear which pre-standard compilers might have supported them.
Ahh this makes some sense