-
Notifications
You must be signed in to change notification settings - Fork 3
Coding Guidelines
Pedro A. Hortas edited this page Apr 25, 2015
·
17 revisions
- Do not indent more than 4 times.
- Use '\t' instead of white-spaces.
- Refer to the following subsections to see the indentation style used on the project.
/* A function with a few arguments */
int func_args_few(int arg1, char *arg2, const char *arg3) {
...;
/* Check for errors */
if (error)
return -1;
/* All good */
return 0;
}
/* A function with lots of arguments */
int func_args_many(
int arg1,
int arg2,
char *arg3,
const char *arg4,
long arg5,
unsigned long long arg6)
{
...;
/* Check for errors */
if (error) {
return -1;
}
/* All good */
return 0;
}
switch (opt) {
case ONE: {
...;
}; break;
case TWO: {
...;
}; break;
default: {
...;
}; break;
}
/* Single */
if (cond1)
...;
/* Multiple */
if (cond1) {
...;
} else if (cond2) {
...;
} else {
...;
}
while (cond) {
...;
}
for (i = 0; cond; i ++) {
...;
}
i ++;
-- i;
var = value;
a < b
b > a
a <= b
b >= a
a == b
b != a
a + b
b += a * c
d = (a + b) * c
- Always use stdint.h types (uint16_t, uint32_t, etc) on variables that can possibly be transmitted to other systems.
- Always use htons(3), htonl(3), ntohs(3) and ntohl(3) on uint16_t and uint32_t type variables that are intended to be transmitted to other systems.
- Grant that your code conforms to C99 and/or C11 (pay special attention to strict aliasing rules).
- Grant that your code conforms to, at least, POSIX.1-2001. If, for some good reason, a non-POSIX compliant optimization is used, that portion of code must be optional (and determined at compile time whether it'll be used or not).
- The usage of external libraries (aside from uCodev libraries, libc and some other POSIX libraries) must be optional. Core features of the project must NOT depend on non-standard libraries.
- If a new, non-core, feature is to be implemented and requires to be linked to non-standard libraries (or any other third-party objects), this feature must be optional and disabled by default.
All technical details of the uSched can be found here. A FAQ and a Getting Started guide are also available.
Quick Links:
- Wiki Home
- Coding Guidelines
- Debugging and Unit Testing
- FAQ
- Getting Started
- Next Development Steps
- Request of Features
- Roadmap
Looking for an overview of the uSched? Check the project README.md.