[clang-tools-extra] [clang-tidy] Add avoid-pragma-once. (PR #140388)

Piotr Zegar via cfe-commits cfe-commits at lists.llvm.org
Sun May 18 09:28:25 PDT 2025


================
@@ -3,10 +3,22 @@
 portability-avoid-pragma-once
 =============================
 
-This check catches pragma once usage.
+Finds uses of ``#pragma once`` and suggests replacing them with standard
+include guards (``#ifndef``/``#define``/``#endif``) for improved portability.
 
-For example:
+`#pragma once` is a non-standard extension, despite being widely supported
+by modern compilers. Relying on it can lead to portability issues in
+environments.
 
-```
-#pragma once // Bad: Avoid pragma once.
-```
+Some older or specialized C/C++ compilers, particularly in embedded systems,
+may not fully support #pragma once.
+
+Also it can fail in certain file system configurations,like network drives
----------------
PiotrZSL wrote:

Try not to start with also, missing space after coma

https://github.com/llvm/llvm-project/pull/140388


More information about the cfe-commits mailing list