teslamotors/fixed-containers

Conflicts with C Macros

Closed this issue · 1 comments

Hello,
maybe this is a special use-case, but some of the constexpr variables, like BLACK and RED conflict with some of the other C-Libraries which also use BLACK and RED Macros for "Colors".

My Workaround right now is to replace BLACK and RED with FIXED_BLACK and FIXED_RED:

namespace fixed_containers::fixed_red_black_tree_detail
{
using NodeIndex = std::size_t;
static constexpr NodeIndex NULL_INDEX = (std::numeric_limits<NodeIndex>::max)();

using Color = bool;
constexpr Color FIXED_BLACK = false;
constexpr Color FIXED_RED = true;
...

This is appropriately one of your styles to write const/constexpr in UPPERCASE, but IMHO this CAN result in conflict with C Macros. May add a PREFIX for the variables or use a more unique name, thx.

Fixed by renaming to

using NodeColor = bool;
constexpr NodeColor COLOR_BLACK = false;
constexpr NodeColor COLOR_RED = true;

Thanks!