[FFmpeg-devel] [PATCH] Implement common show_banner and show_version functions
Tue Sep 25 20:37:41 CEST 2007
On date Monday 2007-09-24 08:58:40 +0200, Benoit Fouet encoded:
> 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.
OK, as I said I'm OK with both, and this solution has also its
> > 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 ?
New patch attached.
Linux user number 337176 (see http://counter.li.org)
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 5260 bytes
Desc: not available
More information about the ffmpeg-devel