Clang format of version 21.1.5 creates a comment at the end of a namespace in a cpp file but does not do the same inside a header file. It can be forced to create a comment by placing an empty comment at the end of a namespace and invoking clang-format. This looks kinda inconvenient to me.
➜ cat foo.h
namespace n {
void foo();
}
➜ cat foo.cpp
namespace n {
void foo() {}
}
➜ clang-format --version
clang-format version 21.1.5
➜ clang-format foo.cpp
namespace n {
void foo() {}
} // namespace n
➜ clang-format foo.h
namespace n {
void foo();
}
➜ cat refined_foo.h
namespace n {
void f();
} //
➜ clang-format refined_foo.h
namespace n {
void f();
} // namespace n
Environment:
OS: Arch Linux x86_64
Kernel: Linux 6.17.7-arch1-1