[pulseaudio-discuss] [PATCH] typedefs.h: Move some typedefs to a separate file

David Henningsson david.henningsson at canonical.com
Fri Nov 27 05:52:04 PST 2015

On 2015-11-27 12:40, Tanu Kaskinen wrote:
> On Thu, 2015-11-26 at 18:29 +0100, David Henningsson wrote:
>> The relationship between sinks, sources, cards, profiles, and ports
>> is becoming ever more intertwined, to the point that if you try to
>> include one file from the other, you're likely to end up with some
>> weird error somewhere else.
> If you add a circular dependency between two headers, you get errors,
> which you can fix by moving the typedefs above the #include lines. I
> don't think those errors are weird or difficult to deal with (once you
> know the fix).

As an example, I was trying to add "#include <pulsecore/device-port.h>" 
to card.h. Both pa_card and pa_device_port have their typedefs above the 
#include lines. Still, that leads to this error:

In file included from ../../src/pulsecore/card.h:29:0,
                  from ../../src/pulsecore/source.h:43,
                  from ../../src/pulsecore/sink.h:38,
                  from ../../src/pulsecore/core.h:49,
                  from ../../src/pulsecore/module.h:31,
                  from ../../src/pulsecore/cli-text.c:28:
../../src/pulsecore/device-port.h:49:5: error: unknown type name 

Maybe that can be worked around some other way, but if I include the 
typedefs.h file, then I don't need to include device-port.h in the first 

> This patch has another potential benefit, though: it allows
> removing includes between headers. If the unnecessary includes are
> removed, that will reduce the need to recompile stuff when changing the
> headers. Currently, if you touch e.g. sink.h, that will trigger a
> rebuild of pretty much everything.


>> Work around this by creating a new typedefs.h, which does not depend
>> on anything else, and just creates a few typedefs.
>> (Can be expanded with more typedefs in the future if the need arises.)
> What's the criteria for deciding whether a typedef should go in
> typdefs.h?

Except those who are already there, I don't have a strong opinion.

David Henningsson, Canonical Ltd.

More information about the pulseaudio-discuss mailing list