Hi Guys,
Re-iterating very old problem. I really wish there was a "standard" clang format available in WDK. Can anyone please share a clang-format file which can be used with KMDF drivers?
[Big team formatting code the way they want]
The reason that there's no "standard" clang-format is that every team, at every company, has their own set of preferences and their own coding styles/standards.
By default at OSR, we write Windows driver that look like standard Microsoft kernel-mode code. But I wrote a driver for a company that absolutely abhorred the use of CamelCase, and absolutely insisted on snake_case.
At OSR, we tend to place a premium on in-line comments and putting "air" (blank lines) around code blocks. At one client for which I wrote a driver (for a non-MSFT operating system) they hate blank lines in code, and they're not so very fond of blocks of in-line comments, either.
So, you see... it depends. How can we have a "standard" clang-format?
clang-format uses a yaml data file to control how you want the code formatted. If i recall correctly it has several built in formatting styles that you can use from the command line or by specifying it in the yaml file.
Many code editors including vscode, emacs, vim, and likely VS support it.
Also 'microsoft' is one of the built-ins, so I don't understand the op's problem.
The absolute worst C format standard was the one that came out of Sun.
Thanks guys. Could not find something that is really customizable for my needs. clang-format has a lot limitations. I think Visual Slick edit is the best for this. (it costs money though)
A while back I used EditorConfig for formatting. It is free and has an extension for vscode and is supported by VS. It was a few years ago, so I checked it out. Looks like not a lot of activity on it in github, but here: https://editorconfig.org/