Josh Coalson
2012-Apr-26 00:19 UTC
[flac-dev] [Flac-dev] pkg-config output and <FLAC/assert.h>
> From: Paul Davis <paul at linuxaudiosystems.com> > To: flac-dev at xiph.org > Cc: > Sent: Friday, March 25, 2011 5:39 AM > Subject: Re: [Flac-dev] pkg-config output and <FLAC/assert.h> > > On Fri, Mar 25, 2011 at 5:32 AM, Erik de Castro Lopo > <mle+la at mega-nerd.com> wrote: >> Hi, >> >> FLAC helpfully provides a flac.pc file. Unfortunately there is a >> nasty interaction between that file and system header files. >> >> If ones installs flac and relies on pkg-config to find the CFLAGS >> one woulf get CFLAGS value of "-I${includedir}/FLAC" which > suggests >> that FLAC header files like <metadata.h> should be included as: >> >> ? ?#include <metadata.h> >> >> However, FLAC also ships an <assert.h> header file. If one writes >> code that wants needs both the Standard C <assert.h> and the FLAC >> header files, we run into a problem, the C compiler finds FLAC's >> <assert.h> instead of the Standard C version. >> >> I believe the correct solution to this problem is the change the >> Cflag value in flac.pc to "-I${includedir}" and then encourage >> people to use: >> >> ? ?#include <FLAC/metadata.h> >> ? ?#include <FLAC/assert.h> >> ? ?#include <assert.h> >> >> which will no longer conflict. >> >> Opinions? > > i recall raising this as an issue about 18 months ago. i certainly > feel that the include style that flac uses now is simply wrong, and > that your suggestion above (which matches the one i made) is > substantially preferable.I didn't follow, which style is wrong?? I never liked lazy search paths like: -I.../include/FLAC #include <metadata.h> because of the potential for conflict with other headers.? The code should be using this style everywhere: -I.../include #include <FLAC/metadata.h> Then there is no problem with #include <FLAC/assert.h>
Erik de Castro Lopo
2012-Apr-26 00:48 UTC
[flac-dev] [Flac-dev] pkg-config output and <FLAC/assert.h>
Josh Coalson wrote:> > From: Paul Davis <paul at linuxaudiosystems.com> > > To: flac-dev at xiph.org > > Cc: > > Sent: Friday, March 25, 2011 5:39 AM > > Subject: Re: [Flac-dev] pkg-config output and <FLAC/assert.h> > > > > On Fri, Mar 25, 2011 at 5:32 AM, Erik de Castro Lopo > > <mle+la at mega-nerd.com> wrote: > >> Hi, > >> > >> FLAC helpfully provides a flac.pc file. Unfortunately there is a > >> nasty interaction between that file and system header files. > >> > >> If ones installs flac and relies on pkg-config to find the CFLAGS > >> one woulf get CFLAGS value of "-I${includedir}/FLAC" which > > suggests > >> that FLAC header files like <metadata.h> should be included as: > >> > >> ? ?#include <metadata.h> > >> > >> However, FLAC also ships an <assert.h> header file. If one writes > >> code that wants needs both the Standard C <assert.h> and the FLAC > >> header files, we run into a problem, the C compiler finds FLAC's > >> <assert.h> instead of the Standard C version. > >> > >> I believe the correct solution to this problem is the change the > >> Cflag value in flac.pc to "-I${includedir}" and then encourage > >> people to use: > >> > >> ? ?#include <FLAC/metadata.h> > >> ? ?#include <FLAC/assert.h> > >> ? ?#include <assert.h> > >> > >> which will no longer conflict. > >> > >> Opinions? > > > > i recall raising this as an issue about 18 months ago. i certainly > > feel that the include style that flac uses now is simply wrong, and > > that your suggestion above (which matches the one i made) is > > substantially preferable. > > I didn't follow, which style is wrong?? I never liked lazy search paths like: > > -I.../include/FLAC > #include <metadata.h> > > because of the potential for conflict with other headers.? The code > should be using this style everywhere: > > -I.../include > #include <FLAC/metadata.h> > > Then there is no problem with > #include <FLAC/assert.h>Correct. The problem is that currently the pkg-config shipped with most distros (ie from the last release) gives this: $ pkg-config --cflags flac -I/usr/include/FLAC This encourages people in client code to do: #include <all.h> which obviously has the potential to cause problems. Instead pkg-config should give: $ pkg-config --cflags flac -I/usr/include/FLAC so that client code can do: #include <FLAC/all.h> I'll submit a patch to fix this. Cheers, Erik -- ---------------------------------------------------------------------- Erik de Castro Lopo http://www.mega-nerd.com/
Erik de Castro Lopo
2012-Apr-26 01:22 UTC
[flac-dev] [Flac-dev] pkg-config output and <FLAC/assert.h>
Erik de Castro Lopo wrote:> The problem is that currently the pkg-config shipped with most distros > (ie from the last release) gives this: > > $ pkg-config --cflags flac > -I/usr/include/FLAC > > This encourages people in client code to do: > > #include <all.h> > > which obviously has the potential to cause problems. > > Instead pkg-config should give: > > $ pkg-config --cflags flac > -I/usr/include/FLAC > > so that client code can do: > > #include <FLAC/all.h> > > I'll submit a patch to fix this.Actually, thats already been fixed in Git: commit 7ae181f27c16e7eca45840ec9171b938b9f86fbc Author: Josh Coalson <jcoalson at users.sourceforce.net> Date: Sat Nov 29 20:56:09 2008 +0000 remove /FLAC++ suffix on include path commit b76d4f817c54c6fcfcb82fe72e38660c1b480774 Author: Josh Coalson <jcoalson at users.sourceforce.net> Date: Sat Nov 29 20:55:52 2008 +0000 remove /FLAC suffix on include path Erik -- ---------------------------------------------------------------------- Erik de Castro Lopo http://www.mega-nerd.com/