There is this nice clang plugin for VS that supports code formatting. It is nice yet it breaks all complex defines:
Say we had:
#include <boost/preprocessor.hpp>
#include <boost/shared_ptr.hpp>
#define NM_PP_VARIADIC_MAX_LENGTH 5
#define NM_PP_TYPE_DECL(z, n, T) \
class BOOST_PP_CAT(T, n )
#define NM_PP_TYPE(z, n, T) \
BOOST_PP_CAT(T, n )
#define NM_PP_ARGUMENT_DECL(z, n, T) \
BOOST_PP_CAT(T, n ) BOOST_PP_CAT(t, n )
This is what we get after formating:
#include <boost/preprocessor.hpp>
#include <boost/shared_ptr.hpp>
#define NM_PP_VARIADIC_MAX_LENGTH 5
#define NM_PP_TYPE_DECL(z, n, T) \
class BOOST_PP_CAT(T, n)
#define NM_PP_TYPE(z, n, T)
BOOST_PP_CAT(T, n)
#define NM_PP_ARGUMENT_DECL(z, n, T)
BOOST_PP_CAT(T, n) BOOST_PP_CAT(t, n)
As you can see such code will not compile and most \
are removed. Is there a way to configure it to not remove \
?
I tried using default configurations like LLVM and looked at formatting arguments but I can not see where such cruel code optimization is defined.
I would say this is caused by the file endings used, usually CR+LF in windows. Try to convert your files to unix style line endings (LF) and it should work.