stop defining & using FALSE & TRUE macros in public headers

Description

Sometimes I get build failures when newly including an ICU header file into other code because some C++ developers like to define enum constants with names FALSE and TRUE. The addition of an ICU header adds our legacy C macro definitions for FALSE and TRUE which breaks compilation of any enum definition with such constants.

I have been trying to change other people's code where possible, but it would be better to not define these macros.

This ticket is split out of , focusing only on public header files (and other changes as needed to keep ICU tools, tests, and samples building).

The C99 and C++11 standards define false and true (although differently), and they can be passed into ICU UBool function parameters. UBool return values anyway work in conditional expressions. That is, other than having followed ICU's example, there is no real need for users of ICU to use the FALSE and TRUE macros.

We cannot change UBool to bool in C API, nor in structs that cross the library boundary, because that would break binary compatibility.

We discussed changing UBool to bool in other C++ API, but that could be confusingly inconsistent, and at this time we are not planning to do so.

Note also that the implementation details for bool (e.g., sizeof) are not defined in the C/C++ standards.

Activity

Show:
Markus Scherer
September 10, 2020, 8:11 PM

reopened to fix the header test

Fixed

Assignee

Markus Scherer

Reporter

Markus Scherer

Components

Labels

None

Reviewer

None

Priority

major

Time Needed

Hours

Fix versions

Configure