如何使Clang-format忽略注释

3
/* xxx/xxx.c 
 * 
 * This file is part of xxx. 
 * 
 * xxx is free software: you can redistribute it and/or modify 
 * it under the terms of the GNU General Public License as published by 
 * the Free Software Foundation, either version 3 of the License, or 
 * (at your option) any later version. 
 * 
 * xxx is distributed in the hope that it will be useful, 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
 * GNU General Public License for more details. 
 * 
 * You should have received a copy of the GNU General Public License 
 * along with xxx. If not, see <https://www.gnu.org/licenses/>
 */ 

这个注释位于我的代码开头,但是clang-format会在每行末尾添加空格。如何让clang-format忽略注释?

1个回答

4

您可以使用// clang-format off禁用代码的格式,并使用// clang-format on再次启用。

// clang-format off

/* xxx/xxx.c 
 * 
 * This file is part of xxx. 
 * 
 * tripl is free software: you can redistribute it and/or modify 
 * it under the terms of the GNU General Public License as published by 
 * the Free Software Foundation, either version 3 of the License, or 
 * (at your option) any later version. 
 * 
 * tripl is distributed in the hope that it will be useful, 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
 * GNU General Public License for more details. 
 * 
 * You should have received a copy of the GNU General Public License 
 * along with xxx. If not, see <https://www.gnu.org/licenses/>
 */ 

// clang-format on


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接