[Qt-creator] indent preprocessor directives

Atlant Schmidt aschmidt at dekaresearch.com
Mon May 7 12:50:14 CEST 2012


> ...for me it's easier to identify #directive in code than hash
> in first column and directive somewhere in the middle of line
> between C++ code.

  I second Konstantin's point.

  I've spent decades becoming accustomed to / training my brain
  to the idea that keywords that begin with a "#" belong to the
  preprocessor and that everything else belongs to the compiler*.
  And I'll bet I'm not alone in this.

  If folks are suddenly going to start writing

#     directive

  then I predict you're going to see a lot of errors that will
  have as their root cause someone's accidental misunderstanding
  of this basic concept. And if you tried to submit code like
  that to my project, as the project's architect, I wouldn't
  accept it.


* "#pragma" aside.

-----Original Message-----
From: qt-creator-bounces+aschmidt=dekaresearch.com at qt-project.org [mailto:qt-creator-bounces+aschmidt=dekaresearch.com at qt-project.org] On Behalf Of Konstantin Tokarev
Sent: Monday, May 07, 2012 05:17
To: Oswald Buddenhagen
Cc: qt-creator at qt-project.org
Subject: Re: [Qt-creator] indent preprocessor directives

07.05.2012, 13:12, "Oswald Buddenhagen" <oswald.buddenhagen at nokia.com>:
> On Mon, May 07, 2012 at 01:00:21PM +0400, ext Konstantin Tokarev wrote:
>>      void foo()
>>      {
>>  #ifdef foo
>>          doSomething();
>>    #ifdef bar
>>          bar();
>>    #else
>>          notBar();
>>    #endif
>>  #endif
>>      }
>     void foo()
>     {
> #ifdef foo
>         doSomething();
> #  ifdef bar
>         bar();
> #  else
>         notBar();
> #  endif
> #endif
>     }
> works, too.
> just see the hash in the first column as a different "syntax space"
> (which it is), and then it makes perfect sense.

I think that good code should be readable without syntax highlighting,
and for me it's easier to identify #directive in code than hash in first
column and directive somewhere in the middle of line between C++
code. Your mileage may vary though.

Qt-creator mailing list
Qt-creator at qt-project.org

 Click https://www.mailcontrol.com/sr/mnufzg8oi0zTndxI!oX7UskfEqpntbSQcXKQXR7bzfVWu43k4rOdx35VvP3f35MiXDvAP4Shm96bYw94u+b0NQ==  to report this email as spam.

This e-mail and the information, including any attachments, it contains are intended to be a confidential communication only to the person or entity to whom it is addressed and may contain information that is privileged. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please immediately notify the sender and destroy the original message.

Thank you.

Please consider the environment before printing this email.

More information about the Qt-creator mailing list