Open asiekierka opened 2 weeks ago
I've spent a few hours with clang-format
and "Artistic Style" https://astyle.sourceforge.net/ and I'm pretty disappointed with the results of the tools in general.
clang-format
:
*
of a multiplication from *
used to declare a pointer.*
multiplication inside a macro will be treated sometimes like a pointer. There are some issues like this with &
as well.extern "C"
statements in all headers will cause all the other elements inside the extern "C"
to be indented, and this can't be disabled manually: https://stackoverflow.com/questions/65866419/unable-to-disable-extern-indentation-with-clang-formatArtistic Style:
*
and &
are pretty broken.In short... for now, let's not do this. I may spend a bit of time writing a document with some broad code style rules, and leave the rest to the discretion of the developer.
That reminds me of a little story from years ago when #3dsdev on EFNet was still active. Someone opened an issue regarding clang-format to add single line if(). One of the devs responded how the code styles they offer are superior and the issue got closed. So yeah, don't rely on these tools too much. It's time consuming but formatting by hand gives the best results.
Well, it looks like libnds is probably an exception. DSWiFi has taken quite a bit of work to manually change a few parts that caused clang-format to freak out. However, I have created a .clang-format
file that generates code that looks basically like what I was aiming for in libnds, and I haven't had to disable it anywhere: https://github.com/blocksds/dswifi/commit/5894e8d8fa50e95d785ed992d25571c126c5d883
Same for libteak: https://github.com/blocksds/libteak/commit/eeb96d7291200191664bc4bff6429651d700f35c
clang-format
exists, let's make use of it.I have no strong opinions here, other than that:
clang-format
provides LLVM, Google, Chromium, Mozilla, WebKit, Microsoft), with some changes of our own,// clang-format off
may need to be used judiciously in areas which define registers and other such constants, as we may end up relying on unique formatting there to make it more readable for a human.