Re: Strange variable declarations in Kernel

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

 



Hi Paul:

This is a GCC extension. For example

struct file_operations fops = {
read: device_read,
write: device_write,
open: device_open,
release: device_release
};

The ANSI way of doing the same is
struct file_operations fops = {
.read = device_read,
.write = device_write,
.open = device_open,
.release = device_release
};

HTH
Manu


On 9/2/05, Paul Duplys <kernel_newbie@xxxxxx> wrote:
Hi all,

in the file "efi.h" located in /fs/partitions in the kernel tree I found
this structure definition:

87.  typedef struct _gpt_entry_attributes {
88.    u64 required_to_function:1;
89.    u64 reserved:47;
90.    u64 type_guid_specific:16;
91.  } __attribute__ ((packed)) gpt_entry_attributes;


Unfortunatelly, my compiler (perhaps?) can't handle this:

In file included from check.c:36:
efi.h:91: Illegal bitfield width
make[4]: *** [check.o] Error 1

I've never seen a variable definition like this before (and google doesn't
work...):

required_to_function:1;

What does the collon after the variable name mean? What does the number
after the collon mean?

In the same file there are few other typedefs of the same form and they use
the datatype u64 (which is defined as unsigned long long in asm/types.h) and
the attribute packed too. But with them there are no compile problems. So I
guess, the problem is the collon and the number after the collon.

Regards and thanks in advance,
Paul

--
5 GB Mailbox, 50 FreeSMS http://www.gmx.net/de/go/promail
+++ GMX - die erste Adresse für Mail, Message, More +++

--
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