SymptomBecause C and C++ share the same formatter, using the following code to make a C program compatible with C++C#ifdef __cplusplus extern "C" { #endif ...... #ifdef __cplusplus } #endif will cause the code inside { } to be formatted haphazardly, leaving the indentation in a mess.Clueclangformat To address this specific problem, change the IndentExternBlock entry in the .clang-format file to NoIndent.
Adjusting .clang-format for extern "C" {
Symptom
Because C and C++ share the same formatter, using the following code to make a C program compatible with C++
will cause the code inside
{ }to be formatted haphazardly, leaving the indentation in a mess.Clue
To address this specific problem, change the
IndentExternBlockentry in the.clang-formatfile toNoIndent.