Issue 986 in include-what-you-use: Circular includes aren't handled correctly

4 views
Skip to first unread message

notifi...@include-what-you-use.org

unread,
Dec 26, 2021, 4:11:59 PM12/26/21
to include-wh...@googlegroups.com
New issue 986 by alejandro-colomar: Circular includes aren't handled correctly
https://github.com/include-what-you-use/include-what-you-use/issues/986

I wrote the following example to reproduce a more complex situation in my header files:

`// a.h:`
```
#pragma once

#include "b.h"

#define a b
```

`// b.h:`
```
#pragma once

#include "a.h"

#define b
#define b2 a
```

I don't think this is wrong, per Google's iwyu guidelines, is it?
Well, iwyu(1) says I should remove the includes:

```
$ iwyu a.h

a.h should add these lines:

a.h should remove these lines:
- #include "b.h" // lines 3-3

The full include-list for a.h:
---
```
```
$ iwyu b.h

b.h should add these lines:

b.h should remove these lines:
- #include "a.h" // lines 3-3

The full include-list for b.h:
---
```

However, if I remove the definition of `b2`(which required `a`), and consequently I also remove the `#include "a.h"`, then iwyu(1) is happy:

`// a.h:`
```
#pragma once

#include "b.h"

#define a b
```

`// b.h:`
```
#pragma once

#define b
```

```
$ iwyu a.h

(a.h has correct #includes/fwd-decls)
```
```
$ iwyu b.h

(b.h has correct #includes/fwd-decls)
```


Reply all
Reply to author
Forward
0 new messages