例如,在 MySQL++ 库中,有一些宏可以用来定义基于 sql 表定义的简单结构,如下所示:
sql_create_6(stock, 1, 6,
mysqlpp::sql_char, item,
mysqlpp::sql_bigint, num,
mysqlpp::sql_double, weight,
mysqlpp::sql_decimal, price,
mysqlpp::sql_date, sdate,
mysqlpp::Null<mysqlpp::sql_mediumtext>, description)
问题在于,clang-format 会以一种更难以阅读的方式重新格式化它(每个参数都换行)。 大多数代码格式化程序都可以识别特殊的 format-off/format-on 注释,但我在 clang-format 手册中没有找到类似的内容。
最佳答案
在较新的版本中,您可以在一段代码周围加上:
// clang-format off
...
// clang-format on
关于c++ - 如何标记一个区域以使 clang-format 不会触及它?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24974919/