- Typecast notation is to be used:
s_ - Static
g_ - Global (public)
sg_ - Static global (modular)
u8 - 8 Bit unsigned integer
u16 - 16 Bit unsigned integer
u32 - 32 Bit unsigned integer
s8 - 8 Bit signed integer
s16 - 16 Bit signed integer
s32 - 32 Bit signed integer
p - Pointer
pp - Pointer to pointer
ppp - Pointer to pointer to pointer....
s - Structure
e - Enumeration
v - Void
And when defining structures and enums:
S - Structure
E - Enumeration
- int, char And other basic types are not allowed for reasons of
- 4 Column tab stops (not spaces!)
- Open and closed curly braces are in the same column - not on the end of
- More than one expression in a conditional must have each condition
surrounded in parenthesis:
if ((sg_u8Flag) || (psBarf))
- if/while statements must always have curly braces even if there is only one line of operation.
- Use macros sparingly, if at all
- Never check against == TRUE. Check against != FALSE. TRUE Is defined to be nonzero, not any specific value.
- Enumerations shall be typedef'd
- Thou shalt use ASSERT() where prudent
- Recommendation: Use if (constant == variable) not if (variable ==
constant) to avoid possible assignment (leaving off a single =).
- #ifdef/#endif is not allowed unless group consensus agrees (to help avoid overuse of #ifdefs
- Comments of // are preferred in code sections and /* */ in headers, but either is allowed
- Nonglobal variables and functions are to be declared as static - always
- The code must not compile with any warnings
- Maximum warnings are used at all times
- No platform specific code in the core
- Each .h file will have a #ifdef _HEADER_H_ #endif header guard
- Variables will not be defined in headers
- When avoidable, procedures are always reversed referenced, not forward
referenced. In other words, if you need to call a procedure within a
module, make sure it's above the reference. Makes things easier to find when doing searches. This isn't always possible, but when possible, this is what should be done.
- Each module in the dynarec core will contain header.c's disclaimer
- Each procedure in the dynarec core will contain procheader.c's comments - filled in - Indentation already provided below each label in the header.
- Function definitions shall look like this:
static void ProcedureName(UINT8 u8Var1,
Each formal parameter is on a separate line.
- No unused variables!
- Thou shalt check all return codes. If return codes aren't used, a comment explicitly stating why it's ignore is required
- gotos are only allowed for error cleanup