User Tools

Site Tools


c_language:c_style

This is an old revision of the document!


General

Naming

int variable, descriptive_variable_name;
 
typedef int own_datatypes_t;
 
void function_names(void);
 
void mylib_library_function_with_prefix(void);
 
typedef enum myenum_t
{
  MYLIB_GLOBAL_SCOPE_ENUM,
} myenum_t;
 
const int constant;
 
#define ANY_DEFINE_OR_MACRO

Embracing

void foo(void)
{
}
 
if(a)
{
}
 
switch(a)
{
  case A:
    break;
  case B:
  case C:
    break;
  default:
    break;
}

Conditional statement whitespaces

if(a == b)
 
// Not any of these
if (a == b)
if( a == b )
 
// Compare to function call
strlen (str)
strlen( str )
c_language/c_style.1613748147.txt.gz · Last modified: 2022/09/12 00:30 (external edit)

Except where otherwise noted, content on this wiki is licensed under the following license: CC0 1.0 Universal
CC0 1.0 Universal Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki