Skip to main content
Filter by
Sorted by
Tagged with
1 vote
0 answers
33 views

I'm trying to setup clang-format but am having issues with a particular behavior. Basically, I want clang-format to prefer breaking function parameter lists over anything else, even if it's empty. How ...
Jacob Bischoff's user avatar
0 votes
1 answer
45 views

I want to get this style for function parameters/arguments: // If they fit on one line: bar(a, b, c); // If not, break them all: bar( a, b, c ); You can get pretty close with these widely-...
Timmmm's user avatar
  • 99.3k
3 votes
1 answer
123 views

Suppose I have a file test.c with the content below. I as a developer have formatted my firmware blob with 8 bytes per line so that when I want to find the byte at offset 0x25 I can easily locate it. #...
Dave's user avatar
  • 935
4 votes
1 answer
157 views

I want my C++ class definitions to have access modifiers indented like below: class Foo { public: Foo(Bar bar); Foo(Bar *bar); }; Foo::Foo(Bar bar) { if () { while () { } }...
Artyom Fedosov's user avatar
0 votes
0 answers
122 views

I’m using CLion and trying to make it insert a space before C++11-style braced-init-lists while keeping the “Cpp11” list style. According to the docs both SpaceBeforeCpp11BracedList: true ...
StrangeChannel's user avatar
0 votes
0 answers
59 views

I am writing C++ in the VS Code app, and am trying to customize the formatting so that it matches the formatting in Visual Studio. In Visual Studio, the formatting of a function looks like this: void ...
Richard's user avatar
  • 401
-1 votes
0 answers
49 views

The following is my .clang-format file: IndentWidth: 2 IndentCaseLabels: true AllowShortEnumsOnASingleLine: false ColumnLimit: 100 BinPackArguments: false BinPackParameters: false ...
Joe Scotto's user avatar
  • 11.1k
-1 votes
0 answers
14 views

Assuming we have a file with C code like this: /** * @brief Test function * * @param i One letter parameter * @param many_words_here Parameter with long name * @return error code or 0 for ...
White Owl's user avatar
  • 1,524
0 votes
0 answers
83 views

I have the following .clang-format: --- BasedOnStyle: WebKit BreakBeforeBraces: Attach BreakConstructorInitializers: BeforeColon ColumnLimit: 0 ContinuationIndentWidth: 4 Cpp11BracedListStyle: false ...
Raildex's user avatar
  • 5,468
-7 votes
1 answer
191 views

I have setup pre-commit hooks clang-format and cpplint for my C++ app. The pre-commit command is pre-commit run -files test_main.cpp The header include is in right order in original file But clang-...
Dinesh's user avatar
  • 1,886
1 vote
1 answer
308 views

I am developing a Zephyr application and want to format all my source files to have the Zephyr coding style. I found the following .clang-format file in the Zephyr repository below. I put this in the ...
Engineer999's user avatar
  • 4,159
2 votes
1 answer
60 views

i.e. How to configure clang-format to automatically format: // Access Methods inline T& operator[](size_t index) { return buffer[index]; } inline T& Get(size_t index) { return buffer[index]; } ...
MarshMilo100's user avatar
1 vote
0 answers
58 views

Code: auto transs = transitions | stdv::filter([alph](const auto trns) { return trns.first == alph; }) | stdv::values | stdv::transform([](auto x) { return x; }) | stdv::as_rvalue; ...
Sourav Kannantha B's user avatar
0 votes
0 answers
52 views

I want clang-format to break a function header on the ) {, when the parameters will be wrapped to newlines, like so: void foo( int a, // ... int b ) { // ... } But when the parameters don't ...
Moritz's user avatar
  • 426
0 votes
1 answer
97 views

New to clang-format so I might be missing something obvious. But I don't like that it's forcing something like this: typedef struct { int a; int b; int c; } my_struct_t; into a single ...
Iguananaut's user avatar
  • 23.8k
2 votes
1 answer
126 views

Clang-format is behaving inconsistently when aligning a struct initialization. I would like the code to be formated like this: struct RAMP ramp = { ramp_init, ramp_compute, ramp_update, ...
Jorge S's user avatar
  • 103
0 votes
2 answers
159 views

I would like a space in-between std::unique_ptr and <boost::thread> in this line: std::unique_ptr<boost::thread> my_thread; You would think SpaceAfterTemplateKeyword: true would work, but ...
xinthose's user avatar
  • 3,927
0 votes
1 answer
28 views

Are there any ClangFormat styles (or other tools) which will handle excessive newlines? With two or more newlines after the function parameter parentheses, as in the example below, none of the styles ...
user2023370's user avatar
  • 11.3k
2 votes
0 answers
117 views

My clang_format mandates the following behavior: namespace test { namespace inner { int test; int test2; } // namespace inner namespace small { } class MockSerializeWriter { }; } // ...
Tomáš Zato's user avatar
0 votes
0 answers
82 views

I have the following .clang-format configuration file: IncludeBlocks: Regroup IncludeCategories: - Regex: '^<[a-z_]+>$' #1 Priority: 1 - Regex: '.*\/libalpha.h[">]$' #2.1 ...
TheDark's user avatar
  • 31
-2 votes
1 answer
107 views

I'm familiar with Rust, and recently I'm going to write a C project. In Rust, we usually embed some code snippets as usage examples directly in the doc comment. However, I found this hard to be ...
Evian's user avatar
  • 1,225
0 votes
1 answer
657 views

I am using clang-format in VS Code to format my C code on macOS, but I encountered a strange issue: I have the following .clang-format configuration: Language: C BasedOnStyle: Google and My VS Code ...
Xinghang Chen's user avatar
4 votes
0 answers
228 views

I'm using VSCode 1.96.4 on Windows with remote to Linux, clang-format 14.0.6, clangd 14.0.6, extension xaver.clang-format 1.9.0, and extension llvm-vs-code-extensions.vscode-clangd 0.1.33, for mostly ...
aschepler's user avatar
  • 72.5k
-1 votes
1 answer
219 views

I've started to use Xcode instead of CLion(it's paid) for c++ programming recently, but I'm very uncomfortable with the default K&D brace style. I can't find a way to configure reformatting the ...
Gabriel LU's user avatar
3 votes
1 answer
138 views

Clang-format says about QualifierAlignment: Warning Setting QualifierAlignment to something other than Leave, COULD lead to incorrect code formatting due to incorrect decisions made due to clang-...
Thomas Weller's user avatar
1 vote
1 answer
76 views

In Visual Studio, I have a project which uses a different pointer alignment for code reformatting than we normally have. I can configure the pointer alignment in Tools/Options and then at Text Editor/...
Thomas Weller's user avatar
1 vote
0 answers
69 views

I'm using the vscode extension C/C++ and in the extension setting I've set Clang_format_style as: { BasedOnStyle: Google, SortIncludes: false, IndentWidth: 4, MaxEmptyLinesToKeep: 3, ...
Manas R. Makde's user avatar
0 votes
1 answer
72 views

My .clang-format file has followings: IncludeBlocks: Regroup SortIncludes: CaseInsensitive I do want to sort the includes, but I don't want includes for standard or 3rd-party headers (#include <&...
soumeng78's user avatar
  • 911
0 votes
1 answer
554 views

I'm running into an issue with clang-format setup in my project. As all my includes are in angled brackets <> I've got and issue with IncludeIsMainRegex. I want to keep something like this: For ...
lorakis's user avatar
  • 23
2 votes
2 answers
83 views

I would like to have clang-format insert a line break after each preprocessor condition after the operators. For example: #if ((CONDITION_A_SWITCH == ENABLED) || (CONDITION_A_SWITCH == ENABLED) || (...
tl-photography.at's user avatar
0 votes
0 answers
16 views

I have a code with a lot of nested blocks. They all end together, and for reference, each } has its own comment: } // end of switch(var) } // loop over cond2 } // end if for cond1 The ...
White Owl's user avatar
  • 1,524
0 votes
0 answers
96 views

The Clang-Format documentation says that starting from version 17.0 the following is available: # Example of usage: SpacesInParens: Custom SpacesInParensOptions: ExceptDoubleParentheses: false ...
Pedroid's user avatar
1 vote
0 answers
138 views

I'm mostly indenting the multi-line template parameters as below. // clang-format off struct Pretty { std::vector< std::pair< size_t, std::vector<float> ...
Caglayan Dokme's user avatar
1 vote
0 answers
75 views

We have a very large codebase from various developers. For many arguments that are written on different lines, there's several ways to do it. I want prevent code, in both styles: foo( arg1 /* ...
KungPhoo's user avatar
  • 948
0 votes
1 answer
62 views

I have the following code enum MyFlag SOME_EMPTY_MACRO( ARG ) { MyEnumValue = 1 << 1 //!< ... }; In my clang-format, I have BraceWrapping.AfterEnum: true This always get transformed to (...
Denis Rouzaud's user avatar
2 votes
1 answer
109 views

Why does clang-format add excessive indentation or line breaks to function arguments like std::move(widget) in complex lambdas? How can I configure it to keep arguments inline or reduce unnecessary ...
Rodrigo's user avatar
  • 1,049
3 votes
0 answers
125 views

I'm using clang-format to format my C code, and I've hit a behavior I can't figure out how to reconfigure. Take this unformatted example code: LongTypeName short_function1(int argument1); void ...
ancientjpeg's user avatar
0 votes
0 answers
62 views

I'm looking for a Clang configuration that will convert code A into code B (see below). My preference is to "explode" functions with 3 or more arguments for personal readability, and I haven'...
okaycoolneat's user avatar
0 votes
0 answers
55 views

I have the following code: function(aaaaaaaaaaaaa, bbbbbbbbbbbbbbbbbbbbbbbb, cccc); ^ └─ ColumnLimit ...
Kelvin Hu's user avatar
  • 1,483
0 votes
1 answer
255 views

Consider this include statement. Notice the extra space after iostream: #include <iostream > msvc will compile this, but gcc does not. So our Windows devs may not see this failure until our ...
Joel's user avatar
  • 161
0 votes
0 answers
34 views

For example, I want my array looks like this std::vector<std::vector<std::vector<int>>> input = { { {1, 3, 5, 7}, {10, 11, 16, 20}, {23, ...
Natsch28's user avatar
3 votes
1 answer
186 views

I want to achieve that the length of a variable/function/etc does never influence the indent of the following lines, or at least as rarely as possible. For example, I already have ...
sebrockm's user avatar
  • 6,072
1 vote
0 answers
60 views

I want to get code like this: typedef struct FooStruct { \t u_int16_t bar;\t /**< Blah */ \t u_int16_t baz;\t /**< Bleh */ } Foo; (where I'm using \t to indicate a 4-column wide tab ...
beyarkay's user avatar
  • 1,173
3 votes
1 answer
399 views

I have the following code: return first_long_function_name(argument) || second_long_function_name(argument) || third_long_function_name(argument); I want it to behave like ...
Isdj's user avatar
  • 1,856
1 vote
1 answer
136 views

If clang-format finds it needs to put arguments on separate lines, I'd rather it put the first argument on the next line, rather than on the current one with subsequent arguments aligning to a random ...
John Graham's user avatar
4 votes
1 answer
5k views

I am using none-ls to configure Clang-Format, version 19.1.0, as an LSP in Neovim, version v0.10.2. I want to use a .clangformat file to change the formatting rules, but I cannot figure out how to ...
whatupo9's user avatar
  • 165
0 votes
1 answer
143 views

I am trying to make the source formatter in stm32cubeide code editor to skip some parts of my code. Normally it just works fine but in some cases I want to have it differently for readability. Take ...
hennep's user avatar
  • 690
0 votes
1 answer
174 views

I have a branch that I've been working on with a few commits. Some of these commits have code that should be formatted with clang-format, but not all code should be formatted. The practical solution ...
MrBerta's user avatar
  • 2,798
3 votes
0 answers
204 views

Given the same .clang-format, the clang-format in CLion behaves differently than the one installed in the OS (Debian clang-format version 14.0.6), I suspect CLion is using clang-format of another ...
Rahn's user avatar
  • 5,565
2 votes
1 answer
169 views

I have a project with some sub-projects, and want clang-format to sort them differently depending on sub-project. Can I have the sub-projects "include" a top-level .clang-format file? (...
John Graham's user avatar

1
2 3 4 5
19