====== Misc ======
[[https://www.kernel.org/doc/html/v4.10/process/coding-style.html|The Linux kernel coding style]]
[[https://google.github.io/styleguide/cppguide.html|Google C++ coding style]]
[[http://web.archive.org/web/20190125125043/http://homepages.inf.ed.ac.uk/dts/pm/Papers/nasa-c-style.pdf|NASA C style guide]]
[[https://pubs.opengroup.org/onlinepubs/9699919799/|POSIX style guide?]]
[[https://web.archive.org/web/20190407233045/http://www.maultech.com/chrislott/resources/cstyle/|C and C++ Style Guides]] -- Archived version of a collection of style guides
[[https://libevent.org/|libevent]] -- Available API to maybe seek inspiration from. Uses callbacks and stuff.
[[https://barrgroup.com/sites/default/files/barr_c_coding_standard_2018.pdf|Embedded C Coding Standard]] -- By Michael Barr
[[https://www2.cs.arizona.edu/~mccann/cstyle.html|Indian Hill C Style Manual]]
====== Things to consider ======
==== 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 )
==== Whitespaces in declarations ====
uint32_t *my_func();
uint32_t* my_func();
uint32_t * my_func();
uint32_t *my_var;
uint32_t* my_var;
uint32_t * my_var;
uint32_t *my_var, *another_var, third_var;
void a_function_with_a_really_long_name_and_argument_list(int that, int makes, int you, int wonder, int where
int and_how, int to, int break_the, int lines);
==== Program flow ====
* Should functions only have one return statement? How/when/why?