You've already forked pgbackrest
mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-09-16 09:06:18 +02:00
Add coding standards for String constants.
This commit is contained in:
17
CODING.md
17
CODING.md
@@ -32,12 +32,27 @@ Type names use camel case with the first letter upper case:
|
||||
|
||||
`#define` constants should be all caps with `_` separators.
|
||||
```c
|
||||
#DEFINE MY_CONSTANT "STRING"
|
||||
#define MY_CONSTANT "STRING"
|
||||
```
|
||||
The value should be aligned at column 69 whenever possible.
|
||||
|
||||
This type of constant should mostly be used for strings. Use enums whenever possible for integer constants.
|
||||
|
||||
**String Constants**
|
||||
|
||||
String constants can be declared using the `STRING_STATIC()` macro for local strings and `STRING_EXTERN()` for strings that will be extern'd for use in other modules.
|
||||
|
||||
Extern'd strings should be declared in the header file as:
|
||||
```c
|
||||
#define SAMPLE_VALUE "STRING"
|
||||
STRING_DECLARE(SAMPLE_VALUE_STR);
|
||||
```
|
||||
And in the C file as:
|
||||
```c
|
||||
STRING_EXTERN(SAMPLE_VALUE_STR, SAMPLE_VALUE);
|
||||
```
|
||||
Static strings declared in the C file are not required to have a `#define` if the `#define` version is not used. Extern'd strings must always have the `#define` in the header file.
|
||||
|
||||
**Enum Constants**
|
||||
|
||||
Enum elements follow the same case rules as variables. They are strongly typed so this shouldn't present any confusion.
|
||||
|
@@ -46,13 +46,32 @@
|
||||
<p><code>#define</code> constants should be all caps with <id>_</id> separators.</p>
|
||||
|
||||
<code-block type="c">
|
||||
#DEFINE MY_CONSTANT "STRING"
|
||||
#define MY_CONSTANT "STRING"
|
||||
</code-block>
|
||||
|
||||
<p>The value should be aligned at column 69 whenever possible.</p>
|
||||
|
||||
<p>This type of constant should mostly be used for strings. Use enums whenever possible for integer constants.</p>
|
||||
|
||||
<p><b>String Constants</b></p>
|
||||
|
||||
<p>String constants can be declared using the <code>STRING_STATIC()</code> macro for local strings and <code>STRING_EXTERN()</code> for strings that will be extern'd for use in other modules.</p>
|
||||
|
||||
<p>Extern'd strings should be declared in the header file as:</p>
|
||||
|
||||
<code-block type="c">
|
||||
#define SAMPLE_VALUE "STRING"
|
||||
STRING_DECLARE(SAMPLE_VALUE_STR);
|
||||
</code-block>
|
||||
|
||||
<p>And in the C file as:</p>
|
||||
|
||||
<code-block type="c">
|
||||
STRING_EXTERN(SAMPLE_VALUE_STR, SAMPLE_VALUE);
|
||||
</code-block>
|
||||
|
||||
<p>Static strings declared in the C file are not required to have a <code>#define</code> if the <code>#define</code> version is not used. Extern'd strings must always have the <code>#define</code> in the header file.</p>
|
||||
|
||||
<p><b>Enum Constants</b></p>
|
||||
|
||||
<p>Enum elements follow the same case rules as variables. They are strongly typed so this shouldn't present any confusion.</p>
|
||||
|
@@ -121,6 +121,10 @@
|
||||
<p>Return <code>IoFilterGroup *</code> from <code>ioFilterGroupAdd()</code>.</p>
|
||||
</release-item>
|
||||
|
||||
<release-item>
|
||||
<p>Add coding standards for <code>String</code> constants.</p>
|
||||
</release-item>
|
||||
|
||||
<release-item>
|
||||
<p>Add missing <code>LOG_DEBUG()</code> macro.</p>
|
||||
</release-item>
|
||||
|
Reference in New Issue
Block a user