bug-indent
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Correctly indenting preprocessor macros in header files with guards


From: Darshit Shah
Subject: Correctly indenting preprocessor macros in header files with guards
Date: Tue, 8 May 2018 16:09:28 +0200
User-agent: NeoMutt/20180323

Hi,

I'm trying to use indent on an existing C source which contains header files
with preprocessor statements.

As is common in C, the headers are all surrounded by guard statements, so the
final header file looks like this:


```
#ifndef _MY_HEADER_H
#define _MY_HEADER_H

#define FOO bar

#endif
```

Here, the `#define` is not really defined one level deep. Yet, using the `-ppi`
option will cause this file to be formatted like this:

```
#ifndef _MY_HEADER_H
#define _MY_HEADER_H

#   define FOO bar

#endif
```

Is there any way to teach GNU Indent about the idea of header guards so as to
prevent it from formatting all preprocessor command in a header file with 1
level too deep of indentation?

-- 
Thanking You,
Darshit Shah
PGP Fingerprint: 7845 120B 07CB D8D6 ECE5 FF2B 2A17 43ED A91A 35B6

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]