teslamotors / fixed-containers

C++ Fixed Containers
MIT License
377 stars 33 forks source link

Conflicts with C Macros #46

Closed abeimler closed 1 year ago

abeimler commented 1 year ago

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.

alexkaratarakis commented 1 year ago

Fixed by renaming to

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

Thanks!