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

Tanu Kaskinen tanuk at iki.fi
Mon Nov 30 08:46:31 PST 2015

On Fri, 2015-11-27 at 14:52 +0100, David Henningsson wrote:
> 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 " 
> 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 
> 'pa_available_t'
> Maybe that can be worked around some other way,

Yes it can, by moving the pa_available_t definition above the
#includes. I did it in "card: add pa_card_profile.ports". (That patch
won't be going to master for other reasons, though.)

> > > 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.

Until someone can give good rationale for using different criteria, I
think any core struct can be moved to typedefs.h. I'm not going to
write such patch, but if someone does, I'm inclined to accept it.


More information about the pulseaudio-discuss mailing list