This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: How my codes comply with gcc code formatting?
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Yury Gribov <y dot gribov at samsung dot com>
- Cc: lin zuojian <manjian2006 at gmail dot com>, Marek Polacek <polacek at redhat dot com>, gcc-patches at gcc dot gnu dot org
- Date: Wed, 5 Mar 2014 08:13:43 +0100
- Subject: Re: How my codes comply with gcc code formatting?
- Authentication-results: sourceware.org; auth=none
- References: <20140305033159 dot GA21008 at ubuntu> <20140305062835 dot GO16545 at redhat dot com> <20140305063542 dot GB21008 at ubuntu> <5316CAA7 dot 5080902 at samsung dot com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Wed, Mar 05, 2014 at 10:56:39AM +0400, Yury Gribov wrote:
> >I'm not sure what you asking for here. But to learn how to format
> >your code, I think just look at the GCC source code and model your
> >code after that.
> >
> > I am not understanding the standard.For example,should I use \t
> > instead of space?Should I use 4 spaces as indent or 2?
>
> My understanding is that GCC coding guidelines
> (http://gcc.gnu.org/contribute.html#standards)
> don't require particular indentation style so you should probably
> stick to a style
> used in particular file (or even particular function).
>
> That said GCC's lack of indentation standard is IMHO rather unfortunate.
That is not true. The indentation style is:
http://www.gnu.org/prep/standards/standards.html#Formatting
(though, some parts of gcc, e.g. libstdc++, use slightly different
indentation/formatting style). The above also mentions particular options
for GNU indent which set various rules. -i2 means indentation is by 2
spaces, and the lack of -nut and -tsN options means that tab size is 8
columns and that in the indentation every 8 spaces should be replaced by a
tab.
Jakub