You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@stdcxx.apache.org by Eric Lemings <Er...@roguewave.com> on 2008/06/13 21:04:52 UTC

Inconsistent indentation in preprocessing directives

 
I was just looking at the indentation in the
$TOPDIR/include/rw/_static_assert.h header.  Why are the defines within
the `#ifndef _RWSTD_NO_STATIC_ASSERT' indented but the directives
outside this #if/#else/#endif block are not?  Should they all be
indented uniformly or not indented at all?

I realize this is not conventional but if we want to indent
preprocessing directives, this file should look like this:

	#ifndef _RWSTD_RW_STATIC_ASSERT_H_INCLUDED
	#  define _RWSTD_RW_STATIC_ASSERT_H_INCLUDED

	#  include <rw/_defs.h>

	...

	#  ifndef _RWSTD_NO_STATIC_ASSERT
	#    define _RWSTD_STATIC_ASSERT(Cond)
	...
	#  else
	#    define _RWSTD_STATIC_ASSERT(Cond,Mesg) static_assert(Cond,
Mesg)
	#  endif   // _RWSTD_NO_STATIC_ASSERT

	#endif   // _RWSTD_RW_STATIC_ASSERT_H_INCLUDED

Otherwise, we shouldn't indent at all.

Thanks,
Brad.

Re: Inconsistent indentation in preprocessing directives

Posted by Martin Sebor <se...@roguewave.com>.
Eric Lemings wrote:
>  
> I was just looking at the indentation in the
> $TOPDIR/include/rw/_static_assert.h header.  Why are the defines within
> the `#ifndef _RWSTD_NO_STATIC_ASSERT' indented but the directives
> outside this #if/#else/#endif block are not?  Should they all be
> indented uniformly or not indented at all?

I agree it's inconsistent but I'm not sure there is much to
be gained from indenting the body of the top level blocks.
The purpose of the indentation is to aid readability and
Since virtually every header is always enclosed in a pair
of #ifdefs, indenting its contents wouldn't do anything to
help in this regard.

Martin

> 
> I realize this is not conventional but if we want to indent
> preprocessing directives, this file should look like this:
> 
> 	#ifndef _RWSTD_RW_STATIC_ASSERT_H_INCLUDED
> 	#  define _RWSTD_RW_STATIC_ASSERT_H_INCLUDED
> 
> 	#  include <rw/_defs.h>
> 
> 	...
> 
> 	#  ifndef _RWSTD_NO_STATIC_ASSERT
> 	#    define _RWSTD_STATIC_ASSERT(Cond)
> 	...
> 	#  else
> 	#    define _RWSTD_STATIC_ASSERT(Cond,Mesg) static_assert(Cond,
> Mesg)
> 	#  endif   // _RWSTD_NO_STATIC_ASSERT
> 
> 	#endif   // _RWSTD_RW_STATIC_ASSERT_H_INCLUDED
> 
> Otherwise, we shouldn't indent at all.
> 
> Thanks,
> Brad.