[U-Boot] [PATCH v2 02/11] S3C24XX: Add core support for Samsung's S3C24XX SoCs
Scott Wood
scottwood at freescale.com
Fri Sep 14 21:17:19 CEST 2012
On Fri, Sep 14, 2012 at 09:07:12PM +0200, Marek Vasut wrote:
> Dear Scott Wood,
>
> > On Fri, Sep 14, 2012 at 08:25:25PM +0200, Marek Vasut wrote:
> > > Dear José Miguel Gonçalves,
> > >
> > > > Hi Marek,
> > > >
> > > > On 14-09-2012 19:03, Marek Vasut wrote:
> > > > > Dear José Miguel Gonçalves,
> > > > >
> > > > > It's getting better :)
> > > >
> > > > Hopefully :-)
> > > >
> > > > > [...]
> > > > >
> > > > >> +
> > > > >> +typedef ulong(*getfreq) (void);
> > > > >
> > > > > Is this used?
> > > >
> > > > In the array declaration bellow...
> > >
> > > Why, these are only values, no ?
> >
> > They're function pointers. If they were values the compiler should
> > complain, because "getfreq" is used as the type of the array.
> >
> > > > >> +static const getfreq freq_f[] = {
> > > > >
> > > > > const array const members, no?
> > > >
> > > > Do you mean I should declare it like this:
> > > >
> > > > static const getfreq const freq[] = { ...
> > >
> > > Yes
> >
> > Why? When can you ever change what an array (not a pointer) points to?
>
> Uh oh ... now I see the stuff with the functions. Crazy
>
> > > > I don't see the point because an array has no other storage besides
> > > > it's elements. Moreover GCC generates the same object code in both
> > > > ways.
> > >
> > > Type checking, if you ever decided to write into the array, it'll prevent
> > > you from doing so.
> >
> > The first const takes care of that.
>
> Doesn't one prevent you from manupulating the elements and the other
> manipulating the array ?
No. These are all identical:
const int foo[];
int const foo[];
const int const foo[];
const const const int const const const foo[];
If it were a pointer, then there would be a difference between these:
const int *foo; (pointed-to data is const)
int *const foo; (pointer itself is const)
const int *const foo; (both are const)
...but still there's no distinction between these:
const int *foo;
const int const *foo;
-Scott
More information about the U-Boot
mailing list