[MPlayer-dev-eng] [PATCH] Re: min() and max() macro definitions

Nico Sabbi nsabbi at tiscali.it
Sat Mar 19 09:36:24 CET 2005


adland wrote:

>>muxer_mpeg.c:996:1: warning: "max" redefined
>>In file included from muxer_mpeg.c:13:
>>aviheader.h:16:1: warning: this is the location of the previous definition
>>muxer_mpeg.c:997:1: warning: "min" redefined
>>aviheader.h:12:1: warning: this is the location of the previous definition
>>
>>Could we have just one set of definitions in a common header?
>>These are different, so some other changes in code may be necessary, too. 
>>    
>>
>
>here is what I found 
>
>HEADERS
>aviheader defines both   MIN and min 
>                                         MIN(a,b) (((a)<(b))?(a):(b))
>                                         min(a,b) (((a)<(b))?(a):(b))
>                                         but not MAX just max
>                                         max(a,b) (((a)>(b))?(a):(b))
>
>
>there is also definition 
>MIN  in  asf.h surrounded by #ifndef
>               MIN(a,b) (((a)<(b))?(a):(b))
>
>
>C FILES
>MAX in demux_mkv.c:#if !defined(MAX) or #if !defined(MIN)
>               MAX(a, b)   ((a)>(b)?(a):(b))
>               MIN(a, b)       ((a)<(b)?(a):(b))
>
>MIN in aviheader.c
>               #define MIN(a,b) (((a)<(b))?(a):(b))
>             
>
>dvbin.c:#define min(a, b) ((a) <= (b) ? (a) : (b))
>mpeg_hdr.c:#define min(a, b) ((a) <= (b) ? (a) : (b))
>muxer_mpeg.c: #define both min and max
>
>just a note that MIN1(a,b) (((a)<(b))?(a):(b))
>             and MIN2(a,b) ((a) <= (b) ? (a) : (b))
>
>are equivalent macros because if a==b then either value is minimal 
>with MIN1 we would return b and MIN2 returns a  - the values are same.
>simmilar with MAX
>
>so yes we can consolidate the macros in one header file
>say called macros.h
>
>deleted all other definitions of MIN,min,MAX,max
>replaced all instances of min with MIN
>replaced all instance of max with MAX
>added includes for macros.h in C files where needed.
>make distclean
>configure
>compiled
>tested
>
>here is the patch
>
>  
>

as far as I'm concerned the patches to demux_ts.c, demux_mpg.c, 
muxer_mpg.c,
mpeg_hdr.c and dvbin.c are ok to commit (I'll leave the rest to the 
other mainteners),
but do we really need all this?

    Nico




More information about the MPlayer-dev-eng mailing list