New issue 980 by a-cristi: Mapping files not working
https://github.com/include-what-you-use/include-what-you-use/issues/980
This is probably not an issue with IWYU, but a lack of understanding on my part, but I can't figure it out just by following the documentation.
I have a header that is a collection of other headers. I want `iwyu` to suggest me to include that, instead of the headers it includes, and to not suggest those other headers.
I'll use a simplified example.
I have the 2 header files and a source file:
```c
// h1.h
#pragma once
#include "h2.h"
#define H1_DEF 1
```
```c
// h2.h
#pragma once
#define H2_DEF 2
```
```c
// s.c
#include "h1.h" // I want this to be considered OK by iwyu
#include <stdio.h>
int main()
{
printf("%d %d\n", H1_DEF, H2_DEF);
return 0;
}
```
Running `iwyu` gives the following result:
```console
$ iwyu -Xiwyu s.c
s.c should add these lines:
#include "h2.h" // for H2_DEF
s.c should remove these lines:
The full include-list for s.c:
#include <stdio.h> // for printf
#include "h1.h" // for H1_DEF
#include "h2.h" // for H2_DEF
---
```
I'm trying to use a mapping file, but it seems to have no effect:
```
[
{ include: ["<h2.h>", "private", "<h1.h>", "public"] }
]
```
Running `iwyu`:
```console
iwyu -Xiwyu --mapping_file=m.imp s.c
s.c should add these lines:
#include "h2.h" // for H2_DEF
s.c should remove these lines:
The full include-list for s.c:
#include <stdio.h> // for printf
#include "h1.h" // for H1_DEF
#include "h2.h" // for H2_DEF
---
```
If I'm using `symbol` it almost works:
```
[
{ symbol: ["H2_DEF", "private", "<h1.h>", "public"] }
]
```
This gives the following result:
```
s.c should add these lines:
#include <h1.h> // for H2_DEF
s.c should remove these lines:
The full include-list for s.c:
#include <h1.h> // for H2_DEF
#include <stdio.h> // for printf
#include "h1.h" // for H1_DEF
---
```
There are 3 problems here:
1. `h1` is suggested twice
2. `<h1.h>` is suggested
3. I'd like to not write one `symbol` line for everything I have in those headers