Re: structure for Super IO chip detection

2010-11-19 Thread Bond
On Fri, Nov 19, 2010 at 1:37 PM, hiren panchasara
 wrote:
> My only attempt was to encourage culture of trying code out for such pure
> programming questions.
Your encouragement does not make any sense,I could not understand how
is that going to work what do I program.
Any how now I understood the concept.


-- 
http://vger.kernel.org/vger-lists.html

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: structure for Super IO chip detection

2010-11-18 Thread Tapas Mishra
On Fri, Nov 19, 2010 at 12:27 PM, hiren panchasara
 wrote:
> You should be able to find how structures are declared/defined/used in any
> good C programming book.
I doubt if such a thing is mentioned on any good C book.
Coming to OP's question.You need to know to understand this is that,
in C/C++, if you initialise part of an array or struct, i.e. supply
fewer initialisation values than there are elements, then the
remainder of the elements in the array/struct are initialised to 0.
So, in this case, if you just initialise the first element to 0, then
you are effectively initialising all elements to 0. This is what's
happening in the example above, except that it's an array of structs,
hence the double { }
superios[NR_SUPERIOS] = { { 0 } };
The code should not have been done
superios[NR_SUPERIOS] = { { 0 ,}, };
These commas are redundant and all compilers will not support it.

-- 
http://mightydreams.blogspot.com

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: structure for Super IO chip detection

2010-11-18 Thread hiren panchasara
On Thu, Nov 18, 2010 at 9:58 PM, Bond  wrote:

> On Thu, Nov 18, 2010 at 10:56 PM, hiren panchasara
>  wrote:
> > Please put it into a small c prog and try it yourself. You will come to
> know
> > in a minute.
> I am not able to understand what program do I make to put thats why I
> asked.
>

A simple C program with only 2 things:
1) structure that you are confused about - simply copy and paste
2) printf statement to see how values are assigned.

Now change the value in 1) while initializing the structure and repeat.

You should be able to find how structures are declared/defined/used in any
good C programming book.

Thanks,
Hiren


Re: structure for Super IO chip detection

2010-11-18 Thread Bond
On Thu, Nov 18, 2010 at 10:56 PM, hiren panchasara
 wrote:
> Please put it into a small c prog and try it yourself. You will come to know
> in a minute.
I am not able to understand what program do I make to put thats why I asked.

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: structure for Super IO chip detection

2010-11-18 Thread hiren panchasara
On Thu, Nov 18, 2010 at 5:47 AM, Bond  wrote:

> On this link
>
> http://lxr.free-electrons.com/source/drivers/parport/parport_pc.c?v=2.6.29#L97
> they defined a structure superio_struct and initialized as
>
> superios[NR_SUPERIOS] = { {0,},};
> I am not able to understand above initialization has what is it
> getting initialized to.
>

Please put it into a small c prog and try it yourself. You will come to know
in a minute.

Thanks,
Hiren


structure for Super IO chip detection

2010-11-18 Thread Bond
On this link
http://lxr.free-electrons.com/source/drivers/parport/parport_pc.c?v=2.6.29#L97
they defined a structure superio_struct and initialized as

superios[NR_SUPERIOS] = { {0,},};
I am not able to understand above initialization has what is it
getting initialized to.

What I deduce till now is superios is a structure array of struct superio_struct
and NR_SUPERIOS is defined as 3 hence an array of structure of size 3
but
superios[0]=??
superios[1]=??
superios[2]=??


I had a look at following links
http://publib.boulder.ibm.com/infocenter/comphelp/v8v101/index.jsp?topic=/com.ibm.xlcpp8a.doc/language/ref/designators.htm
http://gcc.gnu.org/onlinedocs/gcc/Designated-Inits.html
https://www.acrc.bris.ac.uk/RedHat/rhel-gcc-en-4/designated-inits.html
also checked the C books available with me.

This part is not clear to me as to what these individual members are
initialized to.
-- 
http://vger.kernel.org/vger-lists.html

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ