tags:

views:

275

answers:

3

Possible Duplicate:
Why do people use __(double underscore) so much in C++

I was studying the linux kernel programming code.

There aere some data structures and function which starts with double underscore(_ _)

like

_ _ u32  len

how that is different from normal variables

+7  A: 

It means it's a system-reserved name. The C standard says that all names beginning with two underscore, or underscore and capital letter, are reserved for the use of the system or compiler and should not be defined in application code.

Ben Voigt
Spot on........
Matt Joiner
+1  A: 

That's a type, defined in here (as well as few other places).

It is by convention that usually a double underscore in front of a type, variable or function name implies a name that is always reserved, as defined in section 7.1.3 of the current standard (C99).

Michael Foukarakis
+2  A: 

The other answers are correct that it's reserved for the implementation. Of course here Linux should advance out of the 20th century and use the standard type uint32_t rather than the myriad of nonstandard names (__u32, u_int32_t, ...) that plagued legacy Unices..

R..
Those types are defined in exactly the same way they are defined by the standard library headers (stdint.h). Why is it such a big deal if a) they're the same type and b) they're not exported for usage by userspace programs?
Michael Foukarakis
@mfukar Consistency is important from a maintenance standpoint. Using ten different names for the same type not only introduces potential compatibility problems, (say, using specific long, uint, etc types mixed with generic int, the size of which is platform-dependent), it decreases code readability.
David Lively
I tried to understnad the kernel c code but its going over my head. i think i have less understanding with pointers or pointer function inside structures. is there any C book where i can study those topics separately so that i can then read the kernel code.
Mirage
+1 - for being rebellious :-).
Praveen S
I understand where you're coming from. Such ill-considerate cases of type intermixing are rather rare in the linux kernel, I'd dare say. Of course, you'll find the `unsigned long`s all over the syscall implementations; but it doesn't really matter, it's by definition a platform-specific chunk of code, and replacing it with the type with appropriate storage space doesn't help anybody. Also, remember that there's a bunch of people arguing against the use of C99 types in favour of Linux types. I don't know what's up with that. :-)
Michael Foukarakis