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

Måns Rullgård mans
Sun Sep 19 22:52:17 CEST 2010

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

> M?ns Rullg?rd wrote:
>> "Axel Holzinger" <aholzinger at gmx.de> writes:
>> > I want to compile witout optimisation.
>> > Why shouldn't I?
>> Because without optimisation, the code will be unusably slow.
> Use the release build then. You get optimisation, which you like and
> full speed. Let me have zero optimisation and easy debugging.

This reminds me of an old joke:

A man is walking down a dark country lane when he notices a stranger
standing beneath a lone lamp post, staring intently at the ground as
though searching for something.  He greets the stranger and offers his

"I seem to have lost my keys, I think it was over there," the stranger
replies, indicating along the road.

"If you lost them there, then why are you searching here?"

"There is a lamp here, so it is easier to see."

>> > What is the benefit of optimisation in a debug build?
>> What is the benefit of debugging code you do not intend to use?
> To understand the architecture.
> To understand why a special function call fails.
> To understand why another works correct.
> Need more?

I don't see how doing any of the above is related to optimisation
being enabled or not.

> Every now and then in FFmpeg user or libav user I read "Look at the
> code". I want to look at the code while it does process my calls. So I
> want to debug and I don't want to be hindered by optimised away local
> variables, loops, etc.

printf is your friend.

> And still I don't see what is the advantage of an optimised debug
> build. What the hell is the debug build good for anyhow then?

A debug build has full symbol information, including line numbers,
which greatly simplifies the analysis of core dumps and profiling

>> > Using a const expression in a runtime if is obfuscation
>> Code is obfuscated when it is not obvious at a glance what it does.
>> If you find it hard to understand what
>>    if (CONFIG_FOO) do_something();
>> does, you should probably consider a career not involving programming.
> You are referring to how the code WORKS. That is indeed obvious - and
> as well obvious with "AV_IF" instead of "if". I'm referring to how the
> code BUILDS - and that is NOT obvious with "if" and the dependency on
> dead code elimination. It's not even documented in the code. 

It is non-obvious to most people how just about any construct is
turned into machine code, yet they have no trouble understanding the

>> > and besides it's plain bad style.
>> Matter of opinion.  You have made yours clear, as have we 
>> ours.  We happen be the ones making the rules here, not you.
> Halleluja. God has spoken.

Would like that inscribed on stone tablets?

>> > Relying on dead code elimination for making a build succeed is a hack.
>> Is relying on the optimisation to make the code fast enough also a
>> hack?
> No.

OK... so how are we to know which optimisations are a "hack" and which
ones are kosher?

M?ns Rullg?rd
mans at mansr.com

More information about the ffmpeg-devel mailing list