Hello,
I have this preprocessor macros:
-----------
#include
#include
#include
#include <iostream>
#define TRACE(...) \
std::cout << "foo" \
BOOST_PP_SEQ_FOR_EACH_I(LOG_ARGUMENT,, BOOST_PP_VARIADIC_TO_SEQ(__VA_ARGS__));
#define LOG_ARGUMENT(r, data, i, elem) \
<< std::endl << " Argument " << i << ": " << BOOST_PP_STRINGIZE(elem) << " == " << elem
int main(int argc, char *argv[])
{
TRACE();
return 0;
}
-----------
They compile when TRACE has arguments, but not without. Problem is, that LOG_ARGUMENT is called even when no args are
supplied, leading to the expansion:
std::cout << "foo" << std::endl << " Argument " <<
0
<< ": " << "" << " == " << ;;
elem is empty, therefore there is no expression after the last <<
expected primary-expression before »;« token
How can I deal with that?
Thanks,
Florian