PaulStoffregen / OneWire

Library for Dallas/Maxim 1-Wire Chips
http://www.pjrc.com/teensy/td_libs_OneWire.html
595 stars 390 forks source link

Usage of "bool" in portable code #97

Closed robertfchapman closed 9 months ago

robertfchapman commented 3 years ago

Changed OneWire::write_bytes power from "bool" to "uint8_t" for better portability

PaulStoffregen commented 3 years ago

Why do you feel "bool" isn't portable?

robertfchapman commented 3 years ago

I may be being a bit pedantic. As I understand, bool is evaluated to int by most compilers which may be more than one byte. When I do use the data type bool, I specifically use the keywords "true" and "false" or "TRUE" and "FALSE" and not 0 and 1, as 0.1 will evaluate to true. On some micro controllers that I have worked with in the past, the compiler & IDE environment didn't deal well with bool types without specifying an include of bool.h or other workarounds which may or may not have been readily available. Some of the projects that I have worked on required going back to very old environments/architectures to add newer functionality. Many of these are in C and not C++ and depending on the compiler would not handle bool.

I would say that today's architectures and environments may be a bit more forgiving and may be a non issue.

PaulStoffregen commented 9 months ago

Going to consider this a non-issue, as the library is C++ and bool is definitely standard in all C++ versions.