[MPlayer-dev-eng] [PATCH] Fix "initialization discards qualifiers" warnings in cfg-*.h

ubitux ubitux at gmail.com
Thu Sep 9 23:38:22 CEST 2010


On Thu, Sep 09, 2010 at 10:34:39PM +0200, Reimar Döffinger wrote:
> On Thu, Sep 09, 2010 at 01:49:46PM +0200, ubitux wrote:
> > On Thu, Sep 09, 2010 at 07:19:49AM +0200, Reimar Döffinger wrote:
> > > On Wed, Sep 08, 2010 at 11:01:06PM +0200, ubitux wrote:
> > > > The void *p pointer initialization in the m_option array have mixed
> > > > initialization (sometimes with the '&' unary operator, sometimes not). The
> > > > patch also makes this consistent.
> > > 
> > > It's not inconsistent, we don't use & to get the address of an array type,
> > > only for the other types.
> > 
> > Oh well ok… may I ask why?
> 
> Less unnecessary clutter. So mostly no real reason beyond personal taste.
> Anyway, if readability is a concern, some alignment pretty-printing would
> probably help far more than this minor detail.

Well in fact I didn't realized what exactly the problem was. As I
understand it now, this is happening:

   const int a[10];     void *p = a     // MPlayer case, warning
   int a[10];           void *p = a     // no warning
   const int a[10];     void *p = &a    // no warning

Since the void *p has to accept const and non-const values (in MPlayer
design), their is no way to change it. But then, to be logical, should we
remove the constness by casting "a" in void* or just to it implicitly do
that using the '&'?

It's surely a minor detail, but I think having all those warnings may hide
something important…

Do you know what's the behaviour with other compilers? Does the specs say
something about it?

-- 
ubitux


More information about the MPlayer-dev-eng mailing list