<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=http://email.email.llvm.org/c/eJylVktvozoU_jVkcwRKII9mkUWaNKMuqjvSrTTLysABfGtsxjZp8-_vsU1oWnUyU02EeMTn-Z1nrsrT5rHhBlpeNxZyBI2CWSzBKojSbJHd3CyjdAd5b-EeXpgBqSyYXmMSTffRdBvuPxqU0Bsua2BgTx2CbZiFhuhzpKNoOXX_lljRW5SuggIGneLSovYsTs1OMBLxwoWAQjDeBjEMql4WlisJTJbArYFOK6u8IqYRuCxU2zHLc0EfFXHhKJqcI52FksbSM_7ZM8ErTgY4UUoimY3Gc3xmpNPw0nCBnkLRTUOp0MPwDoEHLnnLBOArazuBUba9PHUCwxU-04xMFn1JSrOdsaXgedJE2d0lz2AL9NLwWpIxRcN0lG6hPT11Vs-i7Pa35I6WYPhIayxhVZwFQf3UfaQ4Kl6GNyKySNilNx7DkYlY0vVXuLwdZH5gDFyrkX1NR84OAmRPmbe9tGi1_xxFf78P4Wa5OqILtmFHF1wfdWdCUvho7ogqpMIDe8aKIkqvYBrVixIaFN31iHln3ijWhU_U-AdqrbR7HlGfSIP_U6q4YMbGlGm1hFiBt0NBXMBg0YWiQiCTl6J1C7GuBp4rjv_T246qUlU-v4M9MZlhqE4c6VV_Av1ADbMsmSazcPLIdI3OV3i9WT4t53FXxILL_jWuZT-QNBpZCa0qUTjCThn-OkSDgs2EwHLPtTuK0kNvKGsPlOHuLo4tPWYZ3XIur4XVumC6yIae0LHimdUU2fwE31BapZIPWXBSPeje95qWQjxGnco2IEXyKC0qJYR6MX8Cz9-Fd3jPtuQt3RwaXpx7oaKoBKeWRgJd4TqzNIG1Gutm9aU6Wtx91Dk966RGhT5IGo9c9QZKJO808-2UIKGOhl-q9LOuWXAHapSo3cwYAuLB96Hfhguixe1YdNk2dYde0WIPd17E7EoiPDa-RQNBjh4lX8d0qY797PHdCLn0jQgkdH1OMI_jw5xHWRhVfkxofiTjAztx-F5SWJoSI5djohlQNOBcI900ABV829-STXIgFicnSVrPT-NFlMZVpvsaZghNwRLzvq5JcwL_KhqnYeg21LAGp6QbicHkhioM9W-a0tDyjdV9QfFinUP7gR7v23KulHCnT_jKjTVjgIkSWudd-PTdmwQ84-ldwD-LytbN4YCWUb0unNPCj3DaEkJPPbv1VR9gnApAvyQ51_lq7z38M9cGLH7p3a-VXOtJMuwjLhWdYJcCwdkQe-ozvvuE9cGc84AWkrA6jfF30Pk2dWG3g3w5TSblJivX2ZpNWG8bpTc1O3LZqBemy0mvxaaxtvOYpge6am6bPk9o_Xnrru4R04L0HxZUzAduTI-k4eCWufWk2cznjE0xS1fVrMoWxWw9T9NsXUzX65LNsqqcCJajMBsq2yhNJb6AF0HvVLGTv7eAb9JpStdsSbf5YppkWbXK2bycV8X8ZpGV0XyKLeMicXISpeuJ3niRBJ-hQ-Egeztkxm886A0mCy23Ajdb-D50hschxXbMr3phntD6ufMbJoPD5XJ5T8vl93G53A19euJd2Hj7_wcqcm0x>53889</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            A Pointer Typedef Causes Clang to Claim a Function and Its Prototype Conflict
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          gavinhoward
      </td>
    </tr>
</table>

<pre>
    This might be related to #53886, but I was not sure.

When using a type that has been `typedef`'ed to a pointer type, Clang will claim that a function and its prototype are incompatible if the pointer is `const`-qualified and one uses the `typedef`'ed type while the other does not.

Minimal example:

```
#include <stdlib.h>

typedef unsigned char* my_ptr1;

typedef unsigned char my_int1;

static my_ptr1 g_p1;

void
my_test(const my_ptr1 p1);

void
my_test(const my_int1* p1)
{
        *g_p1 = *p1;
}
```

If the above is saved as `test.c`, this `Makefile` should help:

```
test:
        clang -Werror -Weverything -Wno-cast-align -o test.o -c test.c

clean:
        rm -rf test.o
```

Output of `clang --version`:

```
clang version 13.0.1
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/lib/llvm/13/bin
```

It is the Clang packaged by Gentoo.

If you run `make`, the output is as follows:

```
clang -Werror -Weverything -Wno-cast-align -o test.o -c test.c
test.c:13:1: error: conflicting types for 'my_test'
my_test(const my_int1* p1)
^
test.c:10:1: note: previous declaration is here
my_test(const my_ptr1 p1);
^
1 error generated.
make: *** [Makefile:2: test] Error 1
```

The use case for this is opaque pointer type declarations on public functions, but using the private type on the actual function, which makes it so GDB can actually print the fields of the type when debugging. So I might have this in a public header:

```
typedef struct map* Map;

bool map_exists(const Map m, const void* key);
```

And in the source file, I would have this:

```
typedef struct map {
    ...
} map;

bool map_exists(const map* m, const void* key) {
    ...
}
```

In that case, GDB would print out `m`'s fields if I was debugging in `map_exists()`.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJylVktv4joU_jVhc5QIEp4LFhTKqIvqjnQrzbJykpPEt46dsR0o__4e24HSqsNMNSjKA5_3d165Kk_rp4YbaHndWMgRNApmsQSrIEqzWbZczqN0C3lv4QGOzIBUFkyvMYnGu2i8CfcfDUroDZc1MLCnDsE2zEJD9DnSUTQfu39LrOgtShdBAYNOcWlRexanZisYiThyIaAQjLdBDIOql4XlSgKTJXBroNPKKq-IaQQuC9V2zPJc0EdFXHgRTc6RzkJJY-kZ_-yZ4BUnA5woJZHMRuM5PjPSaTg2XKCnUHTTUCr0YXgXgUcuecsE4CtrO4FRtrk-dQLDFT7TjEwWfUlKs62xpeB50kTZ_TXPYAv00vBakjFFw3SUbqA9PXdWT6Ls7rfkjpbC8JHWWIpVcRYE9XP3keKgeBneiMgixS5d-hhemIglXX2Fy9tB5gfGwLW4sK_oyNlBAdlR5m2uLVrsPo-ivz8EuFmuDujANuzgwPWoOxOSwqO5JaqQCo_sBStClF7BNKoXJTQoutuIeWfeKFaFT9T4B2qttHseUJ9Ig_9TqrhgxsaUabWEWIG3Q0FcwGDRlaJCIJPXonULsa4GnhuO_9P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