Emacs C ++ Mode: Role Allocation and Size

I am using the standard (supplied) Emacs C ++ mode, but I have a slight itch that I am looking to scratch. How will I correctly allocate types inside sizeof and cast in C ++?

For example:

  • A cast

    Type * pointer = reinterpret_cast <Type *> (original);

  • Sizeof

    std::cout << sizeof (Type) << "\n";

+5
source share
1 answer

Add these expressions to yours .emacsor rate them with M-:.

Size (which is easier of two cases)

A regular expression identifies any combination (indicated by a parenthesis expression [...], with respect to syntax, see note below) alphanumeric, spaces and asterisks in parentheses and preceding ones sizeof.

(font-lock-add-keywords 'c++-mode
  '(("\\<sizeof[[:space:]]*(\\([[:alnum:][:space:]*]+\\))"
  1 font-lock-type-face t)))

1 emacs ( \\(...\\)) face font-lock-type-face; t .

M-x customize group [RET] font-lock-faces [RET].

++

, , , ndash; "" , . :

(font-lock-add-keywords 'c++-mode
  '(("\\<[[:alnum:]]+_cast[[:space:]]*<\\([[:alnum:][:space:]*]+\\)>[[:space:]]*(\\([[:alnum:][:space:]*]+\\))"
  (1 font-lock-type-face t)
  (2 font-lock-type-face t))))

, '1 and 2` .

: ++. , emacs , sizeof(int * 32).

, , ; sizeof , . , , C .

+4

All Articles