WARNING_FILTER += allow class="Naming Style Violation" RETAIN_UNNORMALIZED_C_AST = Yes # SYSTEM_INCLUDE_PATHS += identifier_naming_system_header.h # https://barrgroup.com/embedded-systems/books/embedded-c-coding-standard # ------------------ # 5 Data Type Rules: # ------------------ # 5.1.a. The names of all new data types, including structures, unions, and enumerations, shall consist only of lowercase characters and internal underscores and end with '_t'. IDENTIFIER_NAMING_STRUCT_CASE=lower_case # NOTE: This assumes that "lowercase character" includes digits, which may be incorrect. IDENTIFIER_NAMING_STRUCT_SUFFIX=_t IDENTIFIER_NAMING_CLASS_CASE=lower_case IDENTIFIER_NAMING_CLASS_SUFFIX=_t IDENTIFIER_NAMING_UNION_CASE=lower_case IDENTIFIER_NAMING_UNION_SUFFIX=_t IDENTIFIER_NAMING_ENUM_CASE=lower_case IDENTIFIER_NAMING_ENUM_SUFFIX=_t IDENTIFIER_NAMING_TYPEDEF_CASE=lower_case IDENTIFIER_NAMING_TYPEDEF_SUFFIX=_t IDENTIFIER_NAMING_TYPE_ALIAS_CASE=lower_case IDENTIFIER_NAMING_TYPE_ALIAS_SUFFIX=_t # According to Google C++ Style Guide, type template parameters are types and should follow the same naming convention as other types: https://google.github.io/styleguide/cppguide.html#Type_Names # "In the body of the template declaration, the name of a type parameter is a typedef-name which alias the type supplied when the template is instantiated" https://en.cppreference.com/w/cpp/language/template_parameters. IDENTIFIER_NAMING_TYPE_TEMPLATE_PARAMETER_CASE=lower_case IDENTIFIER_NAMING_TYPE_TEMPLATE_PARAMETER_SUFFIX=_t # 5.1.b. All new structures, unions, and enumerations shall be named via a typedef. # 5.1.c. The name of all public data types shall be prefixed with their module name and an underscore. # ------------------ # 6 Procedure Rules: # ------------------ # 6.1.a. No procedure shall have a name that is a keyword of any standard version of the C or C++ programming language. Restricted names include interrupt, inline, class, true, false, public, private, friend, protected, and many others. # 6.1.b. No procedure shall have a name that overlaps a function in the C Standard Library. Examples of such names include strlen, atoi, and memset. # 6.1.c. No procedure shall have a name that begins with an underscore. # 6.1.d. No procedure name shall be longer than 31 characters. # 6.1.e. No function name shall contain any uppercase letters. IDENTIFIER_NAMING_FUNCTION_REGEX+=[^_A-Z][^A-Z]{0,30} # 6.1.f. No macro name shall contain any lowercase letters. IDENTIFIER_NAMING_MACRO_DEFINITION_REGEX=[^a-z]* # 6.1.g. Underscores shall be used to separate words in procedure names. # 6.i.h. Each procedure's name shall be descriptive of its purpose. Note that procedures encapsulate the "actions" of a program and thus benefit from the use of verbs in their names (e.g., adc_read()); this "noun-verb" word ordering is recommended. Alternatively, procedures may be named according to the question they answer (e.g., led_is_on()). # 6.1.i. The names of all public functions shall be prefixed with their module name and an underscore (e.g., sensor_read()). # ----------------- # 7 Variable Rules: # ----------------- # 7.1.a. No variable shall have a name that is a keyword of C, C++, or any other well-known extension of the C programming language, including specifically K&R C and C99. Restricted names include interrupt, inline, restrict, class, true, false, public, private,friend, and protected. # 7.1.b. No variable shall have a name that overlaps with a variable name from the C Standard Library (e.g., errno). # 7.1.c. No variable shall have a name that begins with an underscore. # 7.1.d. No variable name shall be longer than 31 characters. # 7.1.e. No variable name shall be shorter than 3 characters, including loop counters. # 7.1.f. No variable name shall contain any uppercase letters. IDENTIFIER_NAMING_VARIABLE_REGEX+=[^_A-Z][^A-Z]{2,31} # 7.1.g. No variable name shall contain any numeric value that is called out elsewhere, such as the number of elements in an array or the number of bits in the underlying type. # 7.1.h. Underscores shall be used to separate words in variable names. # 7.1.i. Each variable's name shall be descriptive of its purpose. # 7.1.j. The names of any global variables shall begin with the letter 'g'. For example, g_zero_offset. IDENTIFIER_NAMING_GLOBAL_VARIABLE_PREFIX=g # 7.1.k. The names of any pointer variables shall begin with the letter 'p'. For example, p_led_reg. IDENTIFIER_NAMING_GLOBAL_CONSTANT_POINTER_PREFIX=p IDENTIFIER_NAMING_GLOBAL_POINTER_PREFIX=p IDENTIFIER_NAMING_LOCAL_POINTER_PREFIX=p IDENTIFIER_NAMING_LOCAL_CONSTANT_POINTER_PREFIX=p IDENTIFIER_NAMING_POINTER_PARAMETER_PREFIX=p IDENTIFIER_NAMING_CONSTANT_POINTER_PARAMETER_PREFIX=p # 7.1.l. The names of any pointer-to-pointer variables shall begin with the letters 'pp'. For example, pp_vector_table. # 7.1.m. The names of all integer variables containing Boolean information (including 0 vs. non-zero) shall begin with the letter 'b' and phrased as the question they answer. For example, b_done_yet or b_is_buffer_full. # 7.1.n. The names of any variables representing non-pointer handles for objects, e.g., file handles, shall begin with the letter 'h'. For example, h_input_file. # 7.1.o. In the case of a variable name requiring multiple of the above prefixes, the order of their inclusion before the first underscore shall be [g][p|pp][b|h].