Skip to content

Commit 422e975

Browse files
committed
Prefer use of static C keyword over EDK2 type STATIC
A while ago a decision was made on the edk2-devel mailing list that the `STATIC` EDK2 type should be replaced with the C keyword `static`. Following further discussion, it was decided to disallow static local variables to prevent breakage when using GoogleTest. Update the Coding Specification to match. While here, remove the outdated section disallowing static functions since they're no longer a problem. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Rebecca Cran <[email protected]> Reviewed-by: Michael D Kinney <[email protected]>
1 parent bbec647 commit 422e975

File tree

3 files changed

+5
-9
lines changed

3 files changed

+5
-9
lines changed

5_source_files/54_code_file_structure.md

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -269,17 +269,12 @@ other than at the top level of a file as specified by this document.
269269

270270
#### 5.4.2.2 Static
271271

272-
An object declared `STATIC` has either file or block scope.
272+
An object declared `static` has file scope.
273+
Objects may not be declared 'static' within functions.
273274

274275
##### 5.4.2.2.1 Do not reuse an object or function identifier with static storage duration.
275276

276277
Throughout the set of source files defined within a single .inf file, do not
277278
reuse an identifier with static storage duration. The compiler may not be
278279
confused by this, but the user may confuse unrelated variables with the same
279280
name.
280-
281-
##### 5.4.2.2.2 Functions should not be declared STATIC.
282-
283-
Some source-level debuggers are unable to resolve static functions. Until it
284-
can be verified that no one is dependent upon a debugger with this limitation,
285-
it is strongly recommended that functions not be declared static.

5_source_files/56_declarations_and_types.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
Any abstract type that is defined must be constructed from other abstract types
3939
or from common EFI data types.
4040

41-
#### 5.6.1.2 The use of int, unsigned, char, void, static, long is a violation of the coding convention.
41+
#### 5.6.1.2 The use of int, unsigned, char, void, long is a violation of the coding convention.
4242

4343
The corresponding EFI types must be used instead.
4444

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,4 +114,5 @@ Copyright (c) 2006-2017, Intel Corporation. All rights reserved.
114114
| | [#425](https://bugzilla.tianocore.org/show_bug.cgi?id=425) [CCS] clarify line breaking and indentation requirements for multi-line function calls | |
115115
| | [#1656](https://bugzilla.tianocore.org/show_bug.cgi?id=1656) Update all Wiki pages for the BSD+Patent license change with SPDX identifiers | |
116116
| | [#607](https://bugzilla.tianocore.org/show_bug.cgi?id=607) Document code comment requirements for spurious variable assignments | |
117-
| 2.3 | Add 4.2 Directory names section and update File names section for the guidelines of module directory and file naming|September 2022||
117+
| 2.3 | Add 4.2 Directory names section and update File names section for the guidelines of module directory and file naming |September 2022|
118+
| 2.4 | The use of the 'static' C keyword is now preferred over the EDK2 type 'STATIC' |February 2025|

0 commit comments

Comments
 (0)