Faces
CC Mode attempts to use the standard faces for programming languages in accordance with their intended purposes as far as possible. No extra faces are currently provided, with the exception of a replacement face c-invalid-face for emacsen that don’t provide font-lock-warning-face.
Normal comments are fontified in
font-lock-comment-face.Comments that are recognized as documentation (see Documentation Comments) get
font-lock-doc-face(Emacs) orfont-lock-doc-string-face(XEmacs) if those faces exist. If they don’t thenfont-lock-comment-faceis used.String and character literals are fontified in
font-lock-string-face.Keywords are fontified with
font-lock-keyword-face.font-lock-function-name-faceis used for function names in declarations and definitions, and classes in those contexts. It’s also used for preprocessor defines with arguments.Variables in declarations and definitions, and other identifiers in such variable contexts, get
font-lock-variable-name-face. It’s also used for preprocessor defines without arguments.Builtin constants are fontified in
font-lock-constant-faceif it exists,font-lock-reference-faceotherwise. As opposed to the preceding two faces, this is used on the names in expressions, and it’s not used in declarations, even if there happen to be a ‘const’ in them somewhere.font-lock-type-faceis put on types (both predefined and user defined) and classes in type contexts.Label identifiers get
font-lock-constant-faceif it exists,font-lock-reference-faceotherwise.Name qualifiers and identifiers for scope constructs are fontified like labels.
Special markup inside documentation comments are also fontified like labels.
Preprocessor directives get
font-lock-preprocessor-faceif it exists (i.e., XEmacs). In Emacs they getfont-lock-builtin-faceorfont-lock-reference-face, for lack of a closer equivalent.Some kinds of syntactic errors are fontified with
font-lock-warning-facein Emacs. In older XEmacs versions there’s no corresponding standard face, so there a specialc-invalid-faceis used, which is defined to stand out sharply by default.Note that it’s not used for ‘
#error’ or ‘#warning’ directives, since those aren’t syntactic errors in themselves.