Skip to content

Commit 319681d

Browse files
committed
Apply suggestions from PiotrZSL.
1 parent 12a6d58 commit 319681d

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

clang-tools-extra/clang-tidy/portability/AvoidPragmaOnceCheck.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class AvoidPragmaOnceCheck : public ClangTidyCheck {
2424
AvoidPragmaOnceCheck(StringRef Name, ClangTidyContext *Context)
2525
: ClangTidyCheck(Name, Context) {}
2626
bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
27-
return LangOpts.CPlusPlus;
27+
return LangOpts.CPlusPlus || LangOpts.C99;
2828
}
2929

3030
void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP,

clang-tools-extra/docs/clang-tidy/checks/portability/avoid-pragma-once.rst

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ some environments.
1313
Some older or specialized C/C++ compilers, particularly in embedded systems,
1414
may not fully support ``#pragma once``.
1515

16-
Also it can fail in certain file system configurations,like network drives
16+
It can also fail in certain file system configurations,like network drives
1717
or complex symbolic links, potentially leading to compilation issues.
1818

1919
Consider the following header file:
@@ -22,3 +22,14 @@ Consider the following header file:
2222

2323
// my_header.h
2424
#pragma once // warning: avoid 'pragma once' directive; use include guards instead
25+
26+
27+
The warning suggests using include guards:
28+
29+
.. code:: c++
30+
31+
// my_header.h
32+
#ifndef PATH_TO_MY_HEADER_H
33+
#define PATH_TO_MY_HEADER_H
34+
35+
#endif // PATH_TO_MY_HEADER_H

0 commit comments

Comments
 (0)