[FFmpeg-devel] [RFC] full paths in #include directives

Aurelien Jacobs aurel
Thu May 8 15:53:57 CEST 2008


Diego Biurrun wrote:

> On Thu, May 08, 2008 at 09:35:21AM +0100, M?ns Rullg?rd wrote:
> > Diego Biurrun <diego at biurrun.de> writes:
> > 
> > > On Thu, May 08, 2008 at 01:36:11AM +0100, M?ns Rullg?rd wrote:
> > >> Diego Biurrun <diego at biurrun.de> writes:
> > >> 
> > >> > I would like to propose using full paths in all #include
> > >> > directives in FFmpeg, i.e.
> > >> >
> > >> > #include "libavutil/common.h"
> > >> >
> > >> > instead of
> > >> >
> > >> > #include "common.h"
> > >> >
> > >> > The reasons are manyfold:
> > >> >
> > >> > 0) We already expect this from external users.
> > >> >
> > >> > 1) Many header names are not at all unique.  The
> > >> > above-mentioned common.h comes to mind, as do others.
> > >> > Depending on the order of -I flags the right header may or may
> > >> > not be included.
> > >> >
> > >> > This has bitten me several times in MPlayer already.  We now
> > >> > use full paths for FFmpeg #includes in MPlayer, but still -I
> > >> > flags are needed so that the FFmpeg headers themselves can
> > >> > find their dependencies.  But with -Ilibavcodec on the gcc
> > >> > command line '#include <png.h>' picks up the FFmpeg version
> > >> > instead of the libpng header.  Build system kludges can work
> > >> > around this, but the system remains brittle, future FFmpeg
> > >> > changes may necessitate more or updated kludges.
> > >> >
> > >> > 2) The need for -I flags would be reduced internally as well as
> > >> > externally.
> > >> >
> > >> > Attached is an example patch for libpostproc.  If the idea is
> > >> > accepted, I will do the rest of the work myself.
> > >> 
> > >> I say go ahead.  Headers in the same directory as the file
> > >> containing the #include directive probably don't need the full
> > >> paths.  The C99 standard leaves it implementation-defined where
> > >> header files are searched for.  POSIX does, however, specify
> > >> that the directory of the source file be searched first when the
> > >> #include directive uses double-quotes.
> > >
> > > So it may be slightly less portable to use full paths everywhere?
> > 
> > I think you mean the opposite.
> 
> Yes, of course.
> 
> > > I say we go with full paths everywhere then.
> > 
> > I wouldn't bother.  I've never heard of a compiler that didn't
> > search the source directory first.
> 
> I can't help but think that if we don't use full paths for everything
> we will quickly have a mix of both systems again.  Thus, I prefer to
> be consistent.

If all the useless -I are removed, then people won't have a chance to
forget adding full path where it's required. I think that's what is
important, isn't it ?

Aurel




More information about the ffmpeg-devel mailing list