[cfe-dev] [clang-format] Indentation of preprocessor directives
Martin J. O'Riordan via cfe-dev
cfe-dev at lists.llvm.org
Wed Aug 31 01:20:38 PDT 2016
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 ...
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?
śr., 31 sie 2016, 08:16 użytkownik David Chisnall <david.chisnall at cl.cam.ac.uk <mailto:david.chisnall at cl.cam.ac.uk> > napisał:
On 30 Aug 2016, at 21:36, Martin J. O'Riordan via cfe-dev <cfe-dev@ <mailto:cfe-dev at lists.llvm.org> tous upór 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.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the cfe-dev