Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorLeitwolf112026-11-15 15:47:19 +0300
committerLeitwolf112026-11-15 15:47:19 +0300
commit4decba594424532945a35494f52283515d67b579 (patch)
tree7c13d36c24ace0a71021fa8acda0ec0fc7e0eba3
parentfec4661eee5ef6548f9d914a409a496251efcb39 (diff)
downloadprogmasoft-cpp-4decba594424532945a35494f52283515d67b579.tar.gz
Write a returned value as 'return (value);'
clang-format 23 always puts a space after 'return', and no option of the profile turns it off, so the guidelines take that form: 'return (value);' in Formatting 2.4, Control flow 5.2, the README and every example. It leaves the list of what the formatter cannot produce, and clang-format 23.1.5 now leaves every C block of the chapters unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Ji7xZMYjc4zankoc7hGBE1
-rw-r--r--Progmasoft_Core_C_Coding_Guidelines/C11/CONTROL-FLOW.md4
-rw-r--r--Progmasoft_Core_C_Coding_Guidelines/C11/FORMATTING.md10
-rw-r--r--Progmasoft_Core_C_Coding_Guidelines/C11/MEMORY-AND-OWNERSHIP.md10
-rw-r--r--README.md2
4 files changed, 12 insertions, 14 deletions
diff --git a/Progmasoft_Core_C_Coding_Guidelines/C11/CONTROL-FLOW.md b/Progmasoft_Core_C_Coding_Guidelines/C11/CONTROL-FLOW.md
index 47a1f10..090f066 100644
--- a/Progmasoft_Core_C_Coding_Guidelines/C11/CONTROL-FLOW.md
+++ b/Progmasoft_Core_C_Coding_Guidelines/C11/CONTROL-FLOW.md
@@ -16,7 +16,7 @@
## 5.2 Returning
- **A function may return from several places.**
-- **A returned value is written in parentheses**: `return(expression);`.
+- **A returned value is written in parentheses**: `return (expression);`.
- **A `void` function may return early with `return;`**, but should not end with one.
## 5.3 Loops
@@ -72,6 +72,6 @@ FillBuffer(size_t aSize)
gotoFailed:
free(pBuffer);
- return(result);
+ return (result);
}
```
diff --git a/Progmasoft_Core_C_Coding_Guidelines/C11/FORMATTING.md b/Progmasoft_Core_C_Coding_Guidelines/C11/FORMATTING.md
index 68367d6..5c4dd22 100644
--- a/Progmasoft_Core_C_Coding_Guidelines/C11/FORMATTING.md
+++ b/Progmasoft_Core_C_Coding_Guidelines/C11/FORMATTING.md
@@ -14,9 +14,9 @@ int
CalculateResult(int aFirstValue, int aSecondValue)
{
if(aFirstValue < 0)
- return(-1);
+ return (-1);
- return(aFirstValue + aSecondValue);
+ return (aFirstValue + aSecondValue);
}
void
@@ -60,8 +60,8 @@ else
## 2.4 Parentheses and spaces
- **No space between `if`, `for`, `while` or `switch` and its `(`**: `if(`, `else if(`, `switch(state)`.
-- **`return` with a value writes it in parentheses**: `return(result);`. A `void` function may return early with
- `return;`.
+- **`return` with a value writes it in parentheses, after one space**: `return (result);`, the form
+ `clang-format` writes. A `void` function may return early with `return;`.
- **One space after each comma.**
- **Binary arithmetic, bitwise, comparison and assignment operators have a space on each side.** A unary operator (`!`,
`~`, `+`, `-`, `*`, `&`, `++`, `--`) sticks to its operand.
@@ -239,8 +239,6 @@ ReflowComments: false
`clang-format` 23 cannot express every rule above. These are checked in review, and the formatter's output is
corrected where it differs:
-- **`return(value)`**: `clang-format` puts a space after `return` whatever the profile says, and writes
- `return (value);`.
- **Compound literals**: `SpaceAfterCStyleCast` also puts a space before the `{` of a compound literal,
`(Example_tUserData) { 0 }`.
- **An empty `do` body**: `do`, then `{ } while(condition);` is split into `{` and `} while(condition);`.
diff --git a/Progmasoft_Core_C_Coding_Guidelines/C11/MEMORY-AND-OWNERSHIP.md b/Progmasoft_Core_C_Coding_Guidelines/C11/MEMORY-AND-OWNERSHIP.md
index 2881f15..5dc7199 100644
--- a/Progmasoft_Core_C_Coding_Guidelines/C11/MEMORY-AND-OWNERSHIP.md
+++ b/Progmasoft_Core_C_Coding_Guidelines/C11/MEMORY-AND-OWNERSHIP.md
@@ -45,7 +45,7 @@ bool
Example_List_Append(Example_List_tList* aInOut_pList, int aValue)
{
if(aInOut_pList == NULL)
- return(false);
+ return (false);
if(aInOut_pList->count == aInOut_pList->capacity)
{
@@ -56,18 +56,18 @@ Example_List_Append(Example_List_tList* aInOut_pList, int aValue)
else
{
if(aInOut_pList->capacity > SIZE_MAX / 2U)
- return(false);
+ return (false);
newCapacity = aInOut_pList->capacity * 2U;
}
if(newCapacity > SIZE_MAX / sizeof(*aInOut_pList->pValues))
- return(false);
+ return (false);
int* pTemporary = realloc(aInOut_pList->pValues, newCapacity * sizeof(*pTemporary));
if(pTemporary == NULL)
- return(false);
+ return (false);
aInOut_pList->pValues = pTemporary;
aInOut_pList->capacity = newCapacity;
@@ -76,7 +76,7 @@ Example_List_Append(Example_List_tList* aInOut_pList, int aValue)
aInOut_pList->pValues[ aInOut_pList->count ] = aValue;
aInOut_pList->count++;
- return(true);
+ return (true);
}
```
diff --git a/README.md b/README.md
index b7906d3..449275e 100644
--- a/README.md
+++ b/README.md
@@ -109,7 +109,7 @@ them in the same form as the C++ index.
- ISO C11 with `-pedantic-errors`, no extensions but `#pragma once` and `extern "C"`; Clang, `clang-format` and
`clang-tidy` 23.
- Eight spaces, 100 columns, the return type on its own line, braces on their own line, and no braces around a body of
- one statement. `if(`, `return(value);`, `int* pValue`, `values[ index ]`.
+ one statement. `if(`, `return (value);`, `int* pValue`, `values[ index ]`.
- `camelCase` locals with `g`, `s` and one `p` per pointer level as prefixes (`gspUser`); parameters `aCount`,
`aIn_pData`, `aOut_pResult`; functions and tags `PascalCase`; `typedef` `tPascalCase`; enumerators `kPascalCase`;
macros `UPPER_SNAKE_CASE`; public names prefixed by their module, `Example_List_Create`.