【发布时间】:2013-09-11 04:52:56
【问题描述】:
对于支持代码格式化的 VS,有一个不错的 clang plugin。这很好,但它打破了所有复杂的定义:
假设我们有:
#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 )
这是我们格式化后得到的:
#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)
如您所见,此类代码将无法编译,并且大多数 \ 已被删除。有没有办法将其配置为不删除\?
我尝试使用 LLVM 之类的默认配置并查看了 formatting arguments,但我看不出这种残酷的代码优化是在哪里定义的。
【问题讨论】:
标签: c++ visual-studio visual-studio-2012 clang clang-format