C_Coding_Standards - RicoJia/notes GitHub Wiki

  • HUA WEI C standard
    1. 40 - 90% of the time is maintenance. Sometimes half of the team is doing this
    2. Conciseness: Delete obsolete code first.
    3. Have the same style.
    4. Header file: It should really be an interface
      1. Good for having the interfaces there. If there're inline implementation, then the compilation time will be very long.
        • Definitions for internal uses, like macros, definitions, enums shouldn't be there.
      2. Have simple include statements. Do not include things that you don't need. Cuz that might be expanded many more times.
      3. Do not have a headerfile if we don't need a public interface.
      4. May be a good idea to provide a header file with the module name
    5. include guard:
      1. no _ or __, those are for ANSIC.
      2. Don't put comments behind include guard.
    6. Extern
      1. extern C should not have #include. Visual Studio has limitations on it.
      2. extern int Foo(int i) should be declared in header, not in c. If Foo(int i) changes its interface, source file may not be compiled (if there's no changes), then during run time there will be linking issues?
⚠️ **GitHub.com Fallback** ⚠️