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

Måns Rullgård mans
Fri May 9 02:31:41 CEST 2008


Diego Biurrun <diego at biurrun.de> writes:

> On Fri, May 09, 2008 at 12:29:54AM +0100, M?ns Rullg?rd wrote:
>> Diego Biurrun <diego at biurrun.de> writes:
>> 
>> > On Thu, May 08, 2008 at 08:59:51PM +0200, Michael Niedermayer wrote:
>> >> On Thu, May 08, 2008 at 03:52:20PM +0200, Aurelien Jacobs wrote:
>> >> > Diego Biurrun wrote:
>> >> > 
>> >> > > 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.
>> >> > > 
>> >> > I like this proposal, but I would prefer if headers in the same
>> >> > directory don't use full path.
>> >> 
>> >> seconded
>> >
>> > But this only solves half of the problem.  Things like
>> >
>> > #include "png.h"
>> > #include "common.h"
>> >
>> > can still pick up the wrong headers with an unfortunate combination of
>> > -I flags...
>> 
>> Not with a POSIX-compatible compiler:
>> 
>>   Thus, headers whose names are enclosed in double-quotes ( "" ) shall
>>   be searched for first in the directory of the file with the #include
>>   line, then in directories named in -I options, and last in the usual
>>   places.
>> 
>> As I said earlier, we already assume (more or less) a POSIX compiler
>> by using the -I flag in the first place.
>
> Are you sure this guards against the following case?
>
> Imagine that you have a file foo.c that contains
>
> #include "libavutil/avutil.h"
>
> and libavutil/avutil.h contains
>
> #include "common.h"
>
> Will that not look for the common.h sitting next to foo.c?

Read the quoted text again: "in the directory of the file with the
#include line" seems clear enough to me.

-- 
M?ns Rullg?rd
mans at mansr.com




More information about the ffmpeg-devel mailing list