0

VS有一个不错的 clang插件,它支持代码格式化。很好,但它打破了所有复杂的定义:

假设我们有:

#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 之类的默认配置并查看了格式化参数,但我看不到这种残酷的代码优化是在哪里定义的。

4

1 回答 1

0

我会说这是由使用的文件结尾引起的,通常是 Windows 中的 CR+LF。尝试将您的文件转换为 unix 样式的行尾 (LF),它应该可以工作。

于 2013-09-21T23:38:18.780 回答