[MPlayer-dev-eng] [PATCH] encapsulating #define arguments

Arpi arpi at thot.banki.hu
Mon Jan 13 14:53:21 CET 2003


Hi,

> This patch encapsulates arguments for #define in ( ) like
> 
> #define min(a,b) (a<b?a:b) 
> 
> -->
> 
> #define min(a,b) ((a)<(b)?(a):(b))
> 
> That way all #defines can be safely used just like functions can.

hmm. about half of your patch is ok, but the other half is just
useless (for example putting demuxer struct pointers to ()),
and just changes the macros unreadable :(

>  #define M_ST_OFF(struct_type, member)    \
> -    ((void*) &((struct_type*) 0)->member)
> +    ((void*) &(((struct_type)*) 0)->(member))

any examples when this can change anything?

> -#define wsClearWindow( win ) XClearWindow( wsDisplay,win.WindowID )
> +#define wsClearWindow( win ) XClearWindow( wsDisplay,(win).WindowID )

same

imho it's ok to change macro args to (args) when they are used in
arithmetic, but it's nonsense when they are pointers or structs.

so it's ok for mp_msg() stuff, for min()/max() and so, but imho it should
not be done for stuff where args are pointers to some struct or are typedefs.

maybe also pointers to elementary types (char*, void* etc) are ok to change,
as they can be used in arithmetic too (example: strcpy(dst+8,src+2), but i
can't imagine case when dst and (dst) can make difference in effect)


A'rpi / Astral & ESP-team

--
Developer of MPlayer, the Movie Player for Linux - http://www.MPlayerHQ.hu


More information about the MPlayer-dev-eng mailing list