473,394 Members | 1,932 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

linux code, about array initialization.

hi all,

while I read the code from linux sources.

I read the statement

static const struct iw_ioctl_description standard_ioctl[] = {
[SIOCSIWCOMMIT - SIOCIWFIRST] = {
.header_type = IW_HEADER_TYPE_NULL,
},
...
};

I have never read such code. normaly, I will write the code as :

static const struct iw_ioctl_description standard_ioctl[] = {
{
.header_type = IW_HEADER_TYPE_NULL,
},
...
};

anyone would help me? thanks

Nov 15 '05 #1
4 1948
"Anonymousgoogledeja" <as*******@hotmail.com> writes:
while I read the code from linux sources.

I read the statement

static const struct iw_ioctl_description standard_ioctl[] = {
[SIOCSIWCOMMIT - SIOCIWFIRST] = {
.header_type = IW_HEADER_TYPE_NULL,
},
...
};

I have never read such code. normaly, I will write the code as :

static const struct iw_ioctl_description standard_ioctl[] = {
{
.header_type = IW_HEADER_TYPE_NULL,
},
...
};


The [SIOCSIWCOMMIT - SIOCIWFIRST] specifies an array index.
Presumably SIOCSIWCOMMIT-SIOCIWFIRST is an integer constant
expression.

By specifying the index values, you don't necessarily have to give the
array elements in order.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 15 '05 #2
I wonder whether it's gcc specific or ANSI std specific?
Keith Thompson wrote:
"Anonymousgoogledeja" <as*******@hotmail.com> writes:
while I read the code from linux sources.

I read the statement

static const struct iw_ioctl_description standard_ioctl[] = {
[SIOCSIWCOMMIT - SIOCIWFIRST] = {
.header_type = IW_HEADER_TYPE_NULL,
},
...
};

I have never read such code. normaly, I will write the code as :

static const struct iw_ioctl_description standard_ioctl[] = {
{
.header_type = IW_HEADER_TYPE_NULL,
},
...
};


The [SIOCSIWCOMMIT - SIOCIWFIRST] specifies an array index.
Presumably SIOCSIWCOMMIT-SIOCIWFIRST is an integer constant
expression.

By specifying the index values, you don't necessarily have to give the
array elements in order.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.


Nov 15 '05 #3
"Anonymousgoogledeja" <as*******@hotmail.com> writes:
Keith Thompson wrote:
"Anonymousgoogledeja" <as*******@hotmail.com> writes:
> while I read the code from linux sources.
>
> I read the statement
>
> static const struct iw_ioctl_description standard_ioctl[] = {
> [SIOCSIWCOMMIT - SIOCIWFIRST] = {
> .header_type = IW_HEADER_TYPE_NULL,
> },
> ...
> };
>
> I have never read such code. normaly, I will write the code as :
>
> static const struct iw_ioctl_description standard_ioctl[] = {
> {
> .header_type = IW_HEADER_TYPE_NULL,
> },
> ...
> };


The [SIOCSIWCOMMIT - SIOCIWFIRST] specifies an array index.
Presumably SIOCSIWCOMMIT-SIOCIWFIRST is an integer constant
expression.

By specifying the index values, you don't necessarily have to give the
array elements in order.


I wonder whether it's gcc specific or ANSI std specific?


Please don't top-post. Your reply goes below the quoted text, so the
entire article can be read from top to bottom.

Designators in initializers (including both the ".member=value" and
"[index]=value" forms) are a new feature in C99. (The term "ANSI" is
ambiguous; strictly speaking the current 1999 ISO standard is the ANSI
standard, but the term "ANSI" is commonly used to refer to the
1989/1990 ANSI/ISO standard.)

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 15 '05 #4
Anonymousgoogledeja a écrit :
while I read the code from linux sources.

I read the statement

static const struct iw_ioctl_description standard_ioctl[] = {
[SIOCSIWCOMMIT - SIOCIWFIRST] = {
.header_type = IW_HEADER_TYPE_NULL,
},
...
};

I have never read such code. normaly, I will write the code as :

static const struct iw_ioctl_description standard_ioctl[] = {
{
.header_type = IW_HEADER_TYPE_NULL,
},
...
};

anyone would help me? thanks


Read again. 'iw_ioctl_description standard_ioctl' is an *array* of
structure... For an 'absolute' initializing (C99), you also need the index.

--
C is a sharp tool
Nov 15 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
by: Jason | last post by:
Hi, I need a way to use random numbers in c++. In my c++ project, when using the mingw compiler I used a mersenne twister that is publicly available and this did its job well. Now I have...
2
by: Fred Zwarts | last post by:
If I am right, members of a class that are const and not static must be initialized in the initialization part of a constructor. E.g. class C { private: const int I; public: C(); };
19
by: Henry | last post by:
I finally thought I had an understanding of multi dimensional arrays in C when I get this: #include <stdio.h> #define max_x 3 #define max_y 5 int array;
1
by: djinni | last post by:
It's been a while since I've written anything in C, and I was hoping to get some feedback on the following code. As far as I can tell, the program works fine, but I'm not sure I'm cleaning all the...
7
by: B. Wood | last post by:
I have a small program (see below) that demonstrates an error I am getting when I build the program on a linux platform. I first initialize an unsigned char array (lines 16). I then initialize...
4
by: Stephen Mayes | last post by:
I have initialized an array like this. const char matrix = { {0, 1, 2, 3}, {0, 1, 2}, {0, 1} }; gcc, (with no options set,) errors unless I specify
3
by: kk_oop | last post by:
Hi. I recently wrote a simple little template that defines an array that checks attempts to use out of bounds indexes. The only problem is that it does provide the use array style value...
5
by: toton | last post by:
Hi, I can initialize an array of class with a specific class as, class Test{ public: Test(int){} }; Test x = {Test(3),Test(6)}; using array initialization list. (Note Test do NOT have a...
15
by: jamx | last post by:
How can you initialize an array, in the initialization list of a constructor ?? SomeClass { public: SomeClass() : *init here* { } private: int some_array; };
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.