What is the meaning of leading and trailing underscores in Linux kernel identifiers?


I keep running across little conventions like __KERNEL__.

Are the __ in this case a naming convention used by kernel developers or is it a syntax specific reason for naming a macro this way?

There are many examples of this throughout the code.

For example some functions and variables begin with an _ or even __.

Is there a specific reason for this?

It seems pretty widely used and I just need some clarification as to whether these things have a syntactical purpose or is it simply a naming convention.

Furthermore I see lots of user declared types such as uid_t. Again I assume this is a naming convention telling the reader that it is a user-defined type?


There are several cases:

<ul><li>In public facing headers, i.e. anything that libc will be taking over and putting under /usr/include/linux, the standards specify which symbols should be defined and any other symbols specific to the system shall start with underscore and capital letter or two underscores. That's the reason for __KERNEL__ in particular, because it is used in headers that are included both in kernel and in libc and some declarations are different.</li> <li>In internal code, the convention usually is that symbol __something is workhorse for something excluding some management, often locking. That is a reason for things like __d_lookup . Similar convention for system calls is that sys_something is the system call entry point that handles context switch to and from kernel and calls do_something to do the actual work.</li> <li>The _t suffix is standard library convention for typedefs. E.g. size_t, ptrdiff_t, foff_t and such. Kernel code follows this convention for it's internal types too.</li> </ul>


  • Scriptlets inserts arbitrary code into servlet's _jspService method
  • Initializing a string, why is `@` required? [duplicate]
  • cookie in javascript and php
  • How getter should look
  • what happens to finally block in the following cases?
  • Python Floating Point Formatting
  • Compact framework voice recognize API or library
  • How to remove trailing space from marquee?
  • AutoHotKey - how to send control and same key multiple times
  • What are zone turns?
  • How can I manually set the document id in a corpus?
  • How can I include the Ivy dependency and none of its dependencies?
  • CSS - how to trim text output?
  • Bootstrap collapse within a foreach loop
  • Receive custom intent without activity restart
  • NHibernate proxyexception
  • Can't compile Arduino CapSense example
  • can variables be set randomly when declaring them again?
  • Can you pass an array from javascript to asp.net mvc controller action without using a form?
  • Yii2: Finding file and getting path in a directory tree
  • cordova is not defined - cordova.js has already been loaded :: Ionic
  • jQuery: add elements until a particular height is reached
  • Cast between interfaces whose interface signatures are same
  • Combining two different ActiveRecord collections into one
  • WPF ICommand CanExecute(): RaiseCanExecuteChanged() or automatic handling via DispatchTimer?
  • What's the purpose of QString?
  • How solve “Qt: Untested Windows version 10.0 detected!”
  • How to use carriage return with multiple line?
  • C++ Partial template specialization - design simplification
  • Javascript simulate pressing enter in input box
  • Javascript Callbacks with Object constructor
  • How can I use Kendo UI with Razor?
  • How can I get HTML syntax highlighting in my editor for CakePHP?
  • What are the advantages and disadvantages of reading an entire file into a single String as opposed
  • Why joiner is not used after Sequence generator or Update statergy
  • Authorize attributes not working in MVC 4
  • Checking variable from a different class in C#
  • Busy indicator not showing up in wpf window [duplicate]
  • Python/Django TangoWithDjango Models and Databases
  • Net Present Value in Excel for Grouped Recurring CF