You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 26 Next »

  • Do not use identifiers that are already declared
    • e.g., don't name a variable errno
  • Do not pass functions invalid values
  • For floating point exception functions, only pass 0 or bitwise OR of floating point macros
  • Do not modify the string returned by setlocale() or localeconv()
  • Do not call setjmp() in stupid places (eg. header files)
  • Do not call longjmp() before calling setjmp()
  • Do not call va_start() with a parameter declared with the register storage class, of array type, or a type that isn't compatible with the type after default argument promotions
  • Do not try to get the address constant of a bit-field
    • e.g., do not: &(t.member-designator)
  • When functions fail, data structures often have indeterminate contents
    • e.g., wcsxfrm(), wcsftime(), mbrtowc(), wcrtomb(), strxfrm(), strftime()
  • Do not mismatch multibyte conversion states with character sequences in another state
  • Do not change the LC_CTYPE in between calls to character conversion functions
  • Only pass functions the type they ask for
    • We might already have a rule for this, but I couldn't find it
  • If the result of a function cannot be represented, the behavior is undefined
    • e.g., abs(), labs(), llabs(), div(), ldiv(), lldiv().
  • Do not cast a void expression to another type.
  • Ensure expressions are compatible with the return types of the functions they call.
  • Source files should always have a trailing newline.
  • Constant expressions must consist entirely of constant components.
  • Do not access anything through an address constant.
  • Do not declare a function with a type qualifier
  • Do not declare an integer constant macro with a non-integer value, or one out of limits
  • Do not use inconsistent comparison functions
  • Do not use bsearch() on an array not in the proper order
  • In a header name, do not have the characters ', \, ", //, or /* in between the < and > or the characters ', \, //, or /* in between the quotes.
  • Do not compare pointers that point to different objects.
  • Do not have operations with side effects within an initialization list.
  • No labels