Reputation: 12371
I used indent to format my C code and it works very well.
Now I'm working with C++ and I still want to use indent. However, I find that it does not support the class declaration very well. Here is an example:
class Test
{
public:
Test ();
void ttt ();
protected:
virtual void func ();
};
This is a header file named test.h
and after using indent like this: export VERSION_CONTROL=never; indent -bli0 -blf -bls -nbfda -npsl -i4 -ts4 test.h
, it becomes as below:
class Test
{
public:
Test ();
void ttt ();
protected:
virtual void func ();
};
As you see, before public
and protected
, two spaces are added and virtual vodi func();
isn't aligned at all.
So indent doesn't support C++?
Upvotes: 0
Views: 659
Reputation: 79
GNU indent
offers very limited support for C++
code,
but
clang-format will support C++
and other langauges/code like C/Java/JavaScript/JSON/Objective-C/Protobuf/C#
.
Upvotes: 0
Reputation: 263217
No, GNU indent
does not support C++.
Quoting section 1.12 of the GNU indent manual:
While an attempt was made to get indent working for C++, it will not do a good job on any C++ source except the very simplest.
Upvotes: 2