[FFmpeg-devel] Moving if(constant expression) to preprocessor?

Måns Rullgård mans
Sat Sep 18 18:16:51 CEST 2010


"Axel Holzinger" <aholzinger at gmx.de> writes:

> Hi M?ns and all,
>
> M?ns Rullg?rd wrote:
>> "Axel Holzinger" <aholzinger at gmx.de> writes:
>> 
>> > Hi all,
>> >
>> > if compiling FFmpeg code with zero optimisations (even without dead 
>> > code elimination) there are linker errors (undefined references to
>
>> > functions or structs) that come from constructs like i.e. the 
>> > following in libavcodec/allcodecs.c:
>> >
>> > if(CONFIG_##X##_HWACCEL) av_register_hwaccel(&x##_hwaccel); }
>> >
>> > The runtime (lower case) "if" leads to an undefined reference, because 
>> > it is evaluated at runtime and not at compile time.
>> >
>> > If dead code eliminitation optimisation is on, this isn't an issue, 
>> > but with optimisations completely off it is.
>> 
>> Don't do that then.
>
> Hehe, if we all would be so shy, we would still live in caves,
> wouldn't we :-)

This is the first time I have seen FFmpeg referred to as shy.

>> > Is there interest in doing this in a way where already the 
>> > preprocessor is solving this (instead of the optimiser)?
>> 
>> No.
>
> Ah.
>
>> > Then I would try and find a solution based on preprocessor magic.
>> 
>> That is not easily possible.
>
> Says who ;-)

Says I.

> You could leave this up to me or others.
>
> It is possible to write a macro that does the trick and in the end the
> above line would for example look like this:
>
> AV_COND_IF(CONFIG_##X##_HWACCEL, (av_register_hwaccel(&x##_hwaccel)),)

How would AV_COND_IF be defined?

> Wouldn't that still be fine? And it could be done with a few lines of
> generic macro defintions that could go to some generic header.
>
> What would be the disadvantage?

It wouldn't work.

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



More information about the ffmpeg-devel mailing list