-
Notifications
You must be signed in to change notification settings - Fork 3
Coding Guidelines
Pedro A. Hortas edited this page Apr 16, 2015
·
17 revisions
- Do not indent more than 4 times.
- Refer to the following subsections to see the indentation style used on the project.
/* A function with a few arguments */
int func_few_args(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_many_args(
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;
}
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.
- Grant that your code conforms to, at least, POSIX.1-2001. If, for some good reason, an optimization non-POSIX compliant is used, that portion of code must be optional (and determined in compile time whether it'll be used or not).
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.