比如,
cpp
#include <omp.h> #include <cstdio> int main() { #pragma omp parallel for for (int i = 0; i < 10; ++i) { puts("demo"); } return 0; }
希望用 clang-format
格式化成:
cpp
#include <omp.h> #include <cstdio> int main() { #pragma omp parallel for for (int i = 0; i < 10; ++i) { puts("demo"); } return 0; }
迷茫2017-04-17 12:02:08
Clang-format is not currently supported.
For this somewhat special formatting requirement, clang-format provides a one-size-fits-all solution:
cpp
#include <omp.h> #include <cstdio> int main() { // clang-format off #pragma omp parallel for // clang-format on for (int i = 0; i < 10; ++i) { puts("demo"); } return 0; }
As shown above, between the // clang-format off
and // clang-format on
switches, you can keep whatever format you want, clang-format does not matter.
阿神2017-04-17 12:02:08
You won’t have to worry if you write this way
#include <omp.h>
#include <cstdio>
int main()
{
# pragma omp parallel for
...
}