• # and# in macros
    • #: stringified what comes after
    • ##: concatenation
  • What is concatenation ?
    • Concatenation
    • It is often useful to merge two tokens into one while expanding macros. This is called token pasting or token concatenation. The ‘##’ preprocessing operator performs token pasting. When a macro is expanded, the two tokens on either side of each ‘##’ operator are combined into a single token, which then replaces the ‘##’ and the two original tokens in the macro expansion.

## 將左右兩遍的內容結合起來,例子如下:

struct command
{
  char *name;
  void (*function) (void);
};
 
struct command commands[] =
{
  { "quit", quit_command },
  { "help", help_command },

};
#define COMMAND(NAME)  { #NAME, NAME ## _command }
 
struct command commands[] =
{
  COMMAND (quit),
  COMMAND (help),

};

container_of()

BUILD_BUD_ON_ZERO(e)

  • C 語言的 bit-field
    • zero-width bit field 有個規定是必須 unnamed ,再來 zero-width bit field 宣告不會使用到任何空間,但是會強制 structure 中下一個 bit field 對齊到下一個 unit 的 boundary
    • What is zero-width bit field

Linux 核心原始程式碼巨集: maxmin

Reference