-
Notifications
You must be signed in to change notification settings - Fork 324
Coding conventions
When contributing to the Julius source, please follow the code style used in the project. Formatting conventions will be strictly enforced in pull requests to keep the code-base uniform.
For formatting, follow these rules, which are mostly the K&R style:
- For functions, opening and closing braces go on their own line
- For statements within functions: opening brace goes on the same line as the
if
,for
orwhile
statement - Braces are mandatory, even for blocks that are only 1 statement
- One space is required between
if
, etc and their opening parenthesis, and between the closing parenthesis and the opening brace - Pointer variable declaration: the
*
goes next to the variable. Example: usebuilding *b;
, notbuilding* b;
The content of a C file is sorted in the following order, with a blank line between each group:
- Include of the corresponding header, without any path prefixes
- Includes of other files from the project using double quotes, using their full path starting relative to
src
, sorted alphabetically - Includes of external headers, sorted alphabetically
- Constants declared using
#define
- Constants/arrays/etc declared using
static const
- Static function declarations
- Static file variables. For UI-related files, first define the buttons, then the generic
data
container for other variables - Functions, ordered by usage. Prefer to put static functions above where they're first used
For UI window files, keep to the following order:
- Init function, if necessary
- Background draw function and related helper functions
- Foreground draw function and related helper functions
- Input handling functions and related helper functions
- Input button click handlers
- The
show
function
Use snake_case
for everything. For constants, either #define
or const
, use CAPITAL_SNAKE_CASE
to indicate they're constants.
Public functions should contain the file's location in the first part of their name to make it easy to find them. For example, the function game_tick_run()
lives in src/game/tick.c
.
Static function should NOT contain the file's location and should be given an appropriate name for what they do.
Julius information
- Improvements from Caesar 3
- Running Julius
- Command-line options
- Configuration
- Hotkeys
- Touch Support
- MP3 Support
Additional downloads
For developers