What are the most common naming conventions in C?

前端 未结 11 2388
走了就别回头了
走了就别回头了 2020-12-02 04:13

What are the naming conventions commonly use in C? I know there are at least two:

  1. GNU / linux / K&R with lower_case_functions
  2. ? name ? with UpperC
11条回答
  •  悲哀的现实
    2020-12-02 04:20

    There could be many, mainly IDEs dictate some trends and C++ conventions are also pushing. For C commonly:

    • UNDERSCORED_UPPER_CASE (macro definitions, constants, enum members)
    • underscored_lower_case (variables, functions)
    • CamelCase (custom types: structs, enums, unions)
    • uncappedCamelCase (oppa Java style)
    • UnderScored_CamelCase (variables, functions under kind of namespaces)

    Hungarian notation for globals are fine but not for types. And even for trivial names, please use at least two characters.

提交回复
热议问题