[FFmpeg-devel] [PATCH] Implement common show_banner and show_version functions

Benoit Fouet benoit.fouet
Mon Sep 24 08:58:40 CEST 2007


Hi,

Stefano Sabatini wrote:
> On date Friday 2007-09-14 16:44:53 +0200, Stefano Sabatini encoded:
>   
>> On date Wednesday 2007-09-12 20:34:30 +0200, Michael Niedermayer encoded:
>>     

[...]

>>> so why not
>>> static const char *application_name= "my program";
>>> ...
>>>
>>> show_banner(application_name, ...);
>>>       
>> Because in this way you can still define at the top of the file:
>>
>> static const char *application_name= "my program";
>> static const int application_birth_year= 2000;
>>
>> but then use show_banner like this:
>> show_banner("another program", 1000);
>>
>> Furthermore, requiring the definition of program_name and
>> program_birth_name in the program main file when including cmdutils.h
>> isn't necessarily a bad thing, because in this way you're saying:
>> "this is a command util, you *have* to define the program_name and
>> program_birth_year blurb for it or it won't compile".
>>
>> On the other hand if a file doesn't define the main for a command
>> line util, then you have no reasons to include cmdutils.h.
>>     
> [...]
>
> I'm attaching the patches corresponding to the two approaches: I'm OK
> with both of them, with a preference for the first one proposed
> (program_name and program_birth_year declared as extern in cmdutils.c)
> for the abovementioned reasons.
>
>   

i really prefer the one with static variables...
IMHO, you cannot force an application to define globals just to be able
to use one or two functions out of the bunch a header file proposes.

> Index: cmdutils.c
> ===================================================================
> --- cmdutils.c	(revision 10549)
> +++ cmdutils.c	(working copy)
> @@ -26,6 +26,7 @@
>  #include "avformat.h"
>  #include "cmdutils.h"
>  #include "avstring.h"
> +#include "version.h"
>  
>  #undef exit
>  
> @@ -152,6 +153,31 @@
>      }
>  }
>  
> +void show_banner(const char *program_name, const int program_birth_year)
>   

is the const needed for int ?

-- 
Ben
Purple Labs S.A.
www.purplelabs.com




More information about the ffmpeg-devel mailing list