Previous: Macros with ;, Up: Custom Macros


12.3 Noise Macros

In CC Mode, noise macros are macros which expand to nothing, or compiler directives (such as GCC's __attribute__) which play no part in the syntax of the C (etc.) language. Some noise macros are followed by arguments in parentheses (possibly optionally), others are not.

Noise macros can easily confuse CC Mode's analysis of function headers, causing them to be mis-fontified, or even mis-indented. You can prevent this confusion by specifying the identifiers which constitute noise macros.

— User Option: c-noise-macro-names

This variable is a list of names of noise macros which never have parenthesized arguments. Each element is a string, and must be a valid identifier. An element in c-noise-macro-names must not also be in c-noise-macro-with-parens-names. Such an element is treated as whitespace by CC Mode.

— User Option: c-noise-macro-with-parens-names

This variable is a list of names of noise macros which optionally have arguments in parentheses. Each element of the list is a string, and must be a valid identifier. An element in c-noise-macro-with-parens-names must not also be in c-noise-macro-names. For performance reasons, such an element, together with the optional parenthesized arguments, is specially handled, but it is only handled when used in declaration contexts1.

The two compiler directives __attribute__ and __declspec have traditionally been handled specially in CC Mode; for example they are fontified with font-lock-keyword-face. You don't need to include these directives in c-noise-macro-with-parens-names, but doing so is OK.

— Function: c-make-noise-macro-regexps

Call this (non-interactive) function, which sets internal variables, on changing the value of c-noise-macro-names or c-noise-macro-with-parens-names after the major mode's function has run. This function is called by CC Mode's initialization code, after the mode hooks have run.


Footnotes

[1] If this restriction causes your project difficulties, please get in touch with bug-cc-mode@gnu.org.