[Qt-creator] indent preprocessor directives

Konstantin Tokarev annulen at yandex.ru
Mon May 7 11:00:21 CEST 2012



07.05.2012, 12:44, "Oswald Buddenhagen" <oswald.buddenhagen at nokia.com>:
> On Mon, May 07, 2012 at 12:37:30PM +0400, ext Konstantin Tokarev wrote:
>
>>  07.05.2012, 12:30, "Oswald Buddenhagen" <oswald.buddenhagen at nokia.com>:
>>>  On Fri, May 04, 2012 at 06:31:17PM +0300, ext Nikos Chantziaras wrote:
>>>>   The C standard says: [...]
>>>>
>>>>   Indenting preprocessor directives is perfectly acceptable by the standard.
>>>  while this is correct, it's still just stupid to indent preprocessor
>>>  directives with the rest of the code. it is a *pre*-processor. it is a
>>>  semantically different beast, which messes with the C++ AST.
>>  But I think it's perfectly valid to indent them in general, and indent them
>>  respectively to each other.
>
> #ifdef foo
> #  ifdef bar
> #    define say hello
> #  else
> #    define say goodbye
> #  endif
> #else
> #  error U can't do that!
> #endif
>
> that's what i meant by indentation *within* hash directives.

    void foo()
    {
#ifdef foo
        doSomething();
  #ifdef bar
        bar();
  #else
        notBar();
  #endif
#endif
    }

-- 
Regards,
Konstantin



More information about the Qt-creator mailing list