如何让 Clang 格式忽略评论
How to make Clang-format ignore comments
/* 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 将在每一行的末尾尾随 space。如何让 clang-format 忽略评论?
您可以使用 // 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
/* 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 将在每一行的末尾尾随 space。如何让 clang-format 忽略评论?
您可以使用 // 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