A Question on Structure | struct seq_operation | New

R

RAKHE

struct seq_operations {
void * (*start) (struct seq_file *m, loff_t *pos);
void (*stop) (struct seq_file *m, void *v);
void * (*next) (struct seq_file *m, void *v, loff_t *pos);
int (*show) (struct seq_file *m, void *v);
};

const struct seq_operations cpuinfo_op = {
.start =c_start,
.next = c_next,
.stop = c_stop,
.show = show_cpuinfo,
};

I found this snippet in Linux Source Code, i panic on this,

i couldn't understant this part ?

can you use ( . ) operator inside a structure, it is new to me?

Can you someone throw a light on this ?
 
F

Flash Gordon

RAKHE wrote, On 23/12/08 11:30:
It has been in the standard for a bit under a decade (the C99 standard
is so called because it was published in 1999) but a lot of compiler
writers have been slow to implement it and some, e.g. Microsoft, have
hardly started at all. So if you want your code to be portable across a
wide range of compilers you still have to be careful.
nice website...
Thank You !!

That site has at least one significant error. The one I spotted on a
quick look was the meaning "obsolecent". It says:

| This means that compilers are allowed to reject such code or accept it
| with a warning message. In either case, they aren't allowed to ignore
| it.

In fact the standard does not give compilers a license to reject code
because it uses obsolescent features. What the standard actually says is:

| Certain features are obsolescent, which means that they may be
| considered for withdrawal in future revisions of this International
| Standard. They are retained because of their widespread use, but their
| use in new implementations (for implementation features) or new
| programs (for language [6.11] or library features [7.26]) is
| discouraged.

I did not look carefully to see if there are other errors.
 
R

RAKHE

RAKHE wrote, On 23/12/08 11:30:



It has been in the standard for a bit under a decade (the C99 standard
is so called because it was published in 1999) but a lot of compiler
writers have been slow to implement it and some, e.g. Microsoft, have
hardly started at all. So if you want your code to be portable across a
wide range of compilers you still have to be careful.
nice website...
Thank You !!

That site has at least one significant error. The one I spotted on a
quick look was the meaning "obsolecent". It says:

| This means that compilers are allowed to reject such code or accept it
| with a warning message. In either case, they aren't allowed to ignore
| it.

In fact the standard does not give compilers a license to reject code
because it uses obsolescent features. What the standard actually says is:

| Certain features are obsolescent, which means that they may be
| considered for withdrawal in future revisions of this International
| Standard. They are retained because of their widespread use, but their
| use in new implementations (for implementation features) or new
| programs (for language [6.11] or library features [7.26]) is
| discouraged.

I did not look carefully to see if there are other errors.
--
Flash Gordon
If spamming me sent it to (e-mail address removed)
If emailing me use my reply-to address
See the comp.lang.c Wiki hosted by me athttp://clc-wiki.net/

Thank you Gordon, for your information!!
 
L

lovecreatesbeauty

struct seq_operations {
           void * (*start) (struct seq_file *m, loff_t *pos);
          void (*stop) (struct seq_file *m, void *v);
           void * (*next) (struct seq_file *m, void *v, loff_t *pos);
          int (*show) (struct seq_file *m, void *v);
  };

const struct seq_operations cpuinfo_op = {
        .start =c_start,
        .next = c_next,
        .stop = c_stop,
        .show = show_cpuinfo,

};

I found this snippet in Linux Source Code, i panic on this,

i couldn't understant this part ?

can you use ( . ) operator inside a structure, it is new to me?

Can you someone  throw a light on this ?

refer to the C Standard doc, section 6.7.8, paragraph 34:

<quote>
34 EXAMPLE 10 Structure members can be initialized to nonzero
values without depending on their order:

div_t answer = { .quot = 2, .rem = -1 };
</quote>

free C standard draft: http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1124.pdf
 
L

lovecreatesbeauty

n1256.pdf is a newer draft.

Hello Keith, merry Christmas and happy New Year.

I checked the web site again, and it seems that we have a newer
version. It says so on this web page <url:
http://www.open-std.org/jtc1/sc22/wg14/www/projects#9899/>: "The
current draft of the revised C standard is available in N1336."

And text from n1256.pdf and n1336 respectively:
WG14/N1256 Committee Draft — Septermber 7, 2007 ISO/IEC 9899:TC3
WG14/N1336 Committee Draft — August 11, 2008 ISO/IEC 9899:201x
 
K

Keith Thompson

Hello Keith, merry Christmas and happy New Year.

I checked the web site again, and it seems that we have a newer
version. It says so on this web page <url:
http://www.open-std.org/jtc1/sc22/wg14/www/projects#9899/>: "The
current draft of the revised C standard is available in N1336."

And text from n1256.pdf and n1336 respectively:
WG14/N1256 Committee Draft — Septermber 7, 2007 ISO/IEC 9899:TC3
WG14/N1336 Committee Draft — August 11, 2008 ISO/IEC 9899:201x

The difference is that n1256 is an updated draft of the existing C99
standard, with the three Technical Corrigenda merged in, whereas n1336
is a very early draft of the C201X standard, which doesn't yet exist.
n1336 is interesting, but n1256 more closely reflects the current
official status of the language. (And it's been argued that the C90
standard more closely reflects the current actual status of the
language.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top