Closed cxong closed 8 years ago
Move to top (if not done already, mobile sucks) and prefix all macros with RLUTIL_
On second thought, it's better to use static strings because preprocessor ignores namespaces, which might break anyone using something like rlutil::ANSI_RED
. See #45 instead
The problem is that using
const char*
/const std::string
in the header means that if two modules both using rlutil are linked, there will be duplicate symbols, resulting in a link error.The solution used here is to use #defines. This is C so it's an acceptable practice. Another solution would be to use
static const char *
/static const std::string
. There are pros and cons to both; with the former you can doprintf(ANSI_GREEN "hello " ANSI_RED "world!");
; with the latter you can take its address and is a bit more memory efficient.See http://stackoverflow.com/q/1431576/2038264