Reputation: 1093
For example, in the MySQL++ library there are macros that can be used to define simple structs based on sql table definition, like this:
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)
The problem is that clang-format will reformat this in a way that is much more difficult to read (every param on a new line). Most code formatters can recognize special format-off / format-on comments, but I haven't found anything like that in the clang-format manual.
Upvotes: 109
Views: 50703
Reputation: 141
I noticed that
//clang-format off
didn't work but
// clang-format off
did!
The space after //
made all the difference.
Upvotes: 14
Reputation: 2554
In newer version, you can surround a section of code with:
// clang-format off
...
// clang-format on
Upvotes: 187
Reputation: 56557
Try adding a //
comment marker after each line, this may do it. I had the same issue in Eclipse and learned this trick.
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)
Upvotes: 11