I have these macros defined:
#define AL_ASSERT_NO_MSG(x) if (!(x)) { assertDialog(__LINE__, __FILE__); __debugbreak(); }
#define AL_ASSERT_MSG(x, msg) if (!(x)) { assertDialog(msg, __LINE__, __FILE__); __debugbreak(); }
#define GET_MACRO(_1, _2, NAME, ...) NAME
#define AL_ASSERT(...) GET_MACRO(__VA_ARGS__, AL_ASSERT_MSG, AL_ASSERT_NO_MSG)(__VA_ARGS__)
I wanted to have it dispatched to the AL_ASSERT_NO_MSG
macro if I only pass one argument and AL_ASSERT_MSG
if I pass two arguments.
However, when I use the macro like this: AL_ASSERT(false, "Test")
it expanded to if (!(false, "Test")) { assertDialog(23, "C:\\Dev\\c++\\SortingAlgorithms\\AlgorithmVisualizer\\src\\Window.cpp"); __debugbreak(); };
and it does not work.
More information: I am using Visual Studio with MSVC. This is not a solution-based project but a CMake project opened as a folder.
What did I do wrong? Any help is appreciated.