Open Gaochenchang opened 9 months ago
Have some suggestions? Or we can discuss it together
Can anyone help?I will be very grateful.
I have encountered some small problems, but I haven't found a solution yet.
Is there a configuration for customizing types that can be replaced with macros?
How can I remove the space between * and function name? Please note that formatting can be done correctly without using the attribute modifier.
There is an extra space before the} at the end, indicating that clang format-16 does not support this formatting style.
There are extra spaces near the ", but no relevant configuration options were found.
Is there an option to leave two spaces before the end of line comment/? I believe using//is possible, but why can't/ meet the requirements?
There is also a great feature. If the configuration can distinguish between function definitions, structure definitions, enumeration definitions, and macro definitions, it would be great because one set of configurations cannot be fully applicable to the entire code. Currently, I have to use two sets of configurations to format a file.
BasedOnStyle: WebKit
Language: Cpp
IndentWidth: 4
MaxEmptyLinesToKeep: 1
IncludeCategories:
- Regex: '^<.*\.h>'
Priority: 1
- Regex: '^"freertos.*\.h"'
Priority: 2
- Regex: '^"esp_.*\.h"'
Priority: 3
- Regex: '^"audio_.*\.h"'
Priority: 4
SortIncludes: false
InsertBraces: true
PointerAlignment: Right
IndentCaseLabels: true
BraceWrapping:
AfterFunction: true
AfterStruct: false
BreakBeforeBraces: Custom
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignConsecutiveMacros: true
AlignTrailingComments:
Kind: Always
OverEmptyLines: 2
AlignAfterOpenBracket: true
IndentPPDirectives: None
AlignConsecutiveBitFields:
Enabled: true
AcrossEmptyLines: true
AcrossComments: false
SpaceAfterCStyleCast: false
AllowShortLoopsOnASingleLine: true
AllowShortBlocksOnASingleLine: true
Cpp11BracedListStyle: true
SpacesInContainerLiterals: false
SpacesBeforeTrailingComments: 2
SpaceBeforeParens: Custom
SpaceBeforeParensOptions:
AfterControlStatements: true
AfterForeachMacros: true
AfterFunctionDeclarationName: false
AfterFunctionDefinitionName: false
AfterIfMacros: true
AfterOverloadedOperator: false
AfterRequiresInClause: false
AfterRequiresInExpression: true
BeforeNonEmptyParentheses: false
SpaceAroundPointerQualifiers: After
If these questions need to be asked elsewhere, please let me know.
@hnakamura5 Hello~, sorry to bother you, or do you know who can answer some questions.
@llvmbot Hi!
It seems the paren is required around the initializer. I took a glance at the annotation routine in clang-format, I resulted that it cannot recognize the designated initializer outside the context of expression.
#define TEST_CFG_DEFAULT() \
({ \
.type = VIDEO_STREAM_WRITER, \
.transmit_mode = VIDEO_MODE, \
.std_config = { \
.clk_cfg = CLK_DEFAULT_CONFIG(44100), \
.slot_cfg = SLOT_DEFAULT_CONFIG(DATA_BIT_WIDTH_16BIT), \
.gpio_cfg = { \
.invert_flags = { \
.bclk_inv = false, \
.ws_inv = false, \
}, \
}, \
}, \
.chan_cfg = CHAN_TEST_DEFAULT_CONFIG(NUM_0, ROLE_MASTER), \
.use_alc = false, \
.volume = 0, \
})
Still have a problem that \
at the end of line is strangely aligned.
Disabling AlignConsecutiveAssignments
solves this problem. Or setting other base rules (e.g.LLVM, Google) also solves this. But you may not want to take either of these solutions.
These indicate it is possibly a issue of using Webkit style and AlignConsecutiveAssignments
at the same time.
clang-format --version
Problem Description The macro formatting results for structure initialization are abnormal. Is there any way to get the desired result? Thank you for your help. Format content
Desired formatting result
Actual formatting results
.clang-format file content