Re: C structure question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> linux lover <linux_lover2004@xxxxxxxxx> [2005-01-16 14:09]:

2.6:
> static struct packet_type ip_packet_type = {
> 	.type = __constant_htons(ETH_P_IP),
> 	.func = ip_rcv,
> };
>

2.4:
> static struct packet_type ip_packet_type =
> {
> 	__constant_htons(ETH_P_IP),
> 	NULL,	/* All devices */
> 	ip_rcv,
> 	(void*)1,
> 	NULL,
> };

> Why . is used in 2.6 series kernels and not in 2.4
> series?
>

the notion of struct-member names eases reading a lot, doesn't it?
I assume that previous C-compilers were not able to understand this
notion.

>
> Also other structure members are why not
> necessary to define in 2.6 kernel?

I do not know why there is '(void*)1' in 2.4.  Besides that,
somewhere, presumable in news://comp.lang.c, I read that all
struct-members not set explicitely are initialized by zeros.
So, the 2.4 notion saves typing -- and is appropriate since the other
struct-members are explicitely initialized.

HTH.

wbr,
Lukas
-- 
Lukas Ruf           | Wanna know anything about raw |
<http://www.lpr.ch> | IP? -> <http://www.rawip.org> |
eMail Style Guide: <http://www.rawip.org/style.html>|

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux