I need use clang-format to take my source code in a style. I try used the Linux kernel.clang-format, and take some modification in it.
But now one thing didn't come true:
/* This is clang-format result: */
struct one_name {
int * n1; /* Ummmm... */
int n2;
double *p;
};
/* But I wanna this: */
struct one_name {
int *n1; /* The pointer is close to var name. */
int n2;
double *p;
};
How to modify the.clang-format for the "int *n1"?
Make sure .clang-format
is in your project directory, and make sure use
clang-format -style=file yourCode.c
And your .clang-format
should have a line like
---
PointerAlignment: Right
For more options, visit https://clang.llvm.org/docs/ClangFormatStyleOptions.html
I had found out the reason: The version of clang-format and LLVM is too low (6.0.0)!
If use 13.0.0 with the same.clang-format file, "PointerAlignment: Right" can give the good format!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.