Skip to content
GitLab
  • Menu
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • sac2c sac2c
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 395
    • Issues 395
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 22
    • Merge requests 22
  • Deployments
    • Deployments
    • Releases
  • Wiki
    • Wiki
  • External wiki
    • External wiki
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • sac-group
  • sac2csac2c
  • Wiki
  • Tutorials
  • Coding Style

Coding Style · Changes

Page history
Add bit about info struct accesor macros and function definitions to Coding-Style.md authored Feb 28, 2025 by Quinten Cabo's avatar Quinten Cabo
Hide whitespace changes
Inline Side-by-side
tutorials/Coding-Style.md
View page @ 800c1bc5
# Blocks with 1 statement
# Blocks with 1 statement
- The body of an if condition should at preferably have brackets. If the body has just one statement you may leave out the `{}` but in that case put the statement indented on another line. Also only do this if you think it unlikely that you will add more statements to the body later.
**OK:**
......@@ -15,4 +16,41 @@ if ((flags & STMT_BLOCK_RETURN_F) && !parse_error) {
```c
if (flags & STMT_BLOCK_RETURN_F) ret = TCappendAssign (ret, ret_stmt);
```
\ No newline at end of file
```
# Info struct accessor macros
You should not access the fields on the info struct in traversals directly but access it with a macro.
This allows you to potentially change the place your attribute is stored on the original info struct.
The macros should follow the format `INFO_<FIELD_NAME>()`
# Function definitions
Write a function definition like this:
```c
keywords type
name()
{
...
}
```
The keywords and return type first and then on another line the name and arguments.
The `{` goes below the function name.
## Example:
```c
static inline void
destroy_mutex_barrier (void)
{
}
```
Also do not forget to make a doc string with a `@brief` and a description of what the functnion does
and preferably some examples if.
Clone repository
  • concepts
    • Deprecated Modules
    • Globals
    • Named Tuples
    • Overloading
    • Preprocessor
    • Primitive functions
    • Runetime Representations
    • input stdin
    • phm xt
    • ref counting methods
    • type famlies
    • type patterns
  • error messages
    • Anthropomorphic error essages
    • Colored error messages
    • Empty file error
View All Pages