Reputation: 11920
I like Google formatting option for C/C++ extension in VCS. However, there is one aspect I would like to change.
I prefer associating a pointer or a reference to the type declaration:
int& a = b;
int* c = d;
However, Google formatter changes it to:
int &a = b;
int *c = d;
I am wondering if there is a way to override just this formatting aspect. Regards.
Upvotes: 2
Views: 1332
Reputation: 7726
From the clang-format-reference:
DerivePointerAlignment
(bool)
If
true
, analyze the formatted file for the most common alignment of&
and*
. Pointer and reference alignment styles are going to be updated according to the preferences found in the file.PointerAlignment
is then used only as fallback.
Consider an example code:
int b = 10;
int *d = &b;
int & a = b;
int *c = d;
If you try to format this code in VS Code, you will find that the 3rd line has automatically formatted as int &a = b
. Again, consider the same version of code in different style:
int b = 10;
int* d = &b;
int & a = b;
int* c = d;
Now, you will see the 3rd line as: int& a = b
.
Upvotes: 1