[cfe-dev] [clang-format] Indentation of preprocessor directives

Daniel Jasper via cfe-dev cfe-dev at lists.llvm.org
Wed Aug 31 01:44:38 PDT 2016


Can you attach this to https://llvm.org/bugs/show_bug.cgi?id=17362 ?

On Wed, Aug 31, 2016 at 10:20 AM, Martin J. O'Riordan via cfe-dev <
cfe-dev at lists.llvm.org> wrote:

> A good point, I’m not 100% sure if it is legal to precede the first ‘#’
> with whitespace, though it seems to be commonly accepted.  I’ll have to dig
> out my ANSI and ISO C documents.
>
>
>
> I am not familiar with any Opensource project that uses this style, but I
> have seen it used in various companies I have done work for in the past;
> indeed, in one case it was part of their official coding practices.
> Interesting if it is not valid ISO C ;-)  I’ve even seen examples such as:
>
>
>
> /* comment */ #define foo ...
>
>
>
> Thanks,
>
>
>
>             MartinO
>
>
>
> *From:* Curdeius Curdeius [mailto:curdeius at gmail.com]
> *Sent:* 31 August 2016 8:42
> *To:* David Chisnall <david.chisnall at cl.cam.ac.uk>;
> Martin.ORiordan at movidius.com
> *Cc:* Clang Dev <cfe-dev at lists.llvm.org>
> *Subject:* Re: [cfe-dev] [clang-format] Indentation of preprocessor
> directives
>
>
>
> Hi Martin and David, thanks for the interest.
>
>
>
> I've had the same impression as David. But certainly, several modern
> compilers accept indented directives (clang, gcc, mscvc, icc).
>
>
>
> Martin, may you be so kind and give some links to projects that use the
> space-before-hash style, please?
>
>
>
> Anyway, it is pretty straightforward to add both styles. Do you have any
> ideas on naming? Should it be a single option (None, AllAfterHash,
> AllBeforeHash) or 2 options: one defining when to indent and the other -
> how to indent?
>
>
>
> Regards,
>
> Marek
>
> śr., 31 sie 2016, 08:16 użytkownik David Chisnall <
> david.chisnall at cl.cam.ac.uk> napisał:
>
> On 30 Aug 2016, at 21:36, Martin J. O'Riordan via cfe-dev <cfe-dev@  tous
> upór lists.llvm.org <cfe-dev at lists.llvm.org>> wrote:
> >
> > and whitespace indentation preceding the ‘#’ prefixed pre-processing
> directive:
>
> Is doing this even valid?  I was under the impression that the C
> preprocessor required the hash to be on column 0.  I’ve certainly had
> compilers reject code in the past where the preprocessor directives were
> indented accidentally.
>
> David
>
> --
>
> Marek
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20160831/6a0af00e/attachment-0001.html>


More information about the cfe-dev mailing list