You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to run the clang-tidy action however I am getting the following error:
INFO:CPP Linter:Running "clang-tidy-12 --export-fixes=clang_tidy_output.yml -checks=boost-*,bugprone-*,performance-*,readability-*,portability-*,modernize-*,clang-analyzer-*,cppcoreguidelines-* --extra-arg= src/main.cpp"
DEBUG:CPP Linter:Output from clang-tidy:
/usr/include/wchar.h:35:10: error: 'stddef.h' file not found [clang-diagnostic-error]
#include <stddef.h>
I am not getting this error on my local PC or with any of my GH Actions build scripts, only the clang-tidy action throws this error. How to fix/ignore this?
I will try that in a bit. Any chance you have a GitHub action file I can CTRL + C ;)
Its a bit old (untested for a few months), but it should still work with any runner on github: Try this code snippet in the README on master. You'll still have to tweak it for your project (obviously), but its a good start.
Thanks! Will try that one out. Just thinking, could it have something to do with git submodules? Because the referenced .h file is only used in one of my submodules. I tried to ignore the entire folder, but it didn't help sadly..
Like I said we've looked into it and got stumped. This problem has been reported from repos that don't use submodules. Our test repo also uses a submodule, but any submodule's path is automatically ignored by cpp-linter. It wouldn't make sense to tell cpp-linter to analyze someone else's repo that your using in your repo, although it could be done with the --ignore option.
The problem that I see is that clang-tidy doesn't know where to find stddef.h when analyzing any header that includes it in the C std libs. The fact that this doesn't happen locally makes this problem hard to diagnose.
Its not specific to Ubuntu runners either. Windows runners show the problem too. It does seem to happen with clang-tidy-12 more than others, but it still does happen with other clang-tidy versions. My best guess is that the runner's C std lib is not the version that clang-tidy was built for (??) 🤷🏼
I think this issue should have been fixed in the latest release, #103 (comment)
If you could not provide your cpp-linter YAML config file, it's hard to tell what exactly the reason is.
This still eludes me... I think it has something to do with certain versions of clang-tidy and the installed C std libs. A while back, I found a stackoverflow suggestion that recommended using the C std lib from LLVM project (instead of the OS-specific PPA), but I don't think that solution is the right approach here.
@GewoonJaap did you find a fix for your private repository? Because with this error the cpp-linter is not really usable as it flags basically every file.
@2bndy5 Additionally we have other problems with the linter. Multiple header files are not found, although the compiler does not have a problem with it and we do a complete build within the pipeline, so that the compile_commands.json can be used. Probably in correlation with this error, some functions are marked as "can be made static" which are already declared static in the corresponding header file. So there seems to be a general problem with finding the correct headers. Do you have any idea how to fix this?
From the output of the above problematic job, it looks like cpp-linter-action doesn't use native binaries.
Found a installed version of clang-format: 12.0.1 at /usr/lib/llvm-12/bin/clang-format
downloading clang-format (version 12)
Installing clang-format-12 to /home/runner/.local/bin/
symbolic link created /home/runner/.local/bin/clang-format
Found a installed version of clang-tidy: 12.0.1 at /usr/lib/llvm-12/bin/clang-tidy
downloading clang-tidy (version 12)
Installing clang-tidy-12 to /home/runner/.local/bin/
symbolic link created /home/runner/.local/bin/clang-tidy
Try adding version and setting it to '14' might fix 'stddef.h' file not found
TBH, our python script doesn't do anything special. It simply finds source files and feeds them to clang-format and/or clang-tidy. The problems you're reporting here sound more like problems with clang-tidy. Since I didn't author anything in the clang project, I can't confidently make any sound suggestions. It would be better to be able to reproduce this locally, but we've been unsuccessful on that front.
That said, have you tried using a different version of clang-tidy? ubuntu-latest (currently Ubuntu-22.04) ships with v12, v13, and v14, so I'd recommend trying those because, as I said before, I think this problem is largely related to using certain versions of clang-tidy with certain version of the C/C++ std libs. It should be noted that each major version of the clang project isn't fully backward compatible, so the specified version is important.
Probably in correlation with this error, some functions are marked as "can be made static" which are already declared static in the corresponding header file.
You're PR covers so many files, its not good to assume that the problems are related. In fact, this is the first I'm hearing about this error. My first impression makes me think there's a discrepancy between the implementation file and the header, but IDK.
We currently don't have a plan to support filtering the output captured from clang-tidy, and we cannot support using a special set of rules for certain files (which should be possible with multiple .clang-tidy config files).
Try adding version and setting it to '14' might fix 'stddef.h' file not found
Good catch @shenxianpeng ! If using the native v12 binary is desired, then the version option should specify 12.0.1 which might include the a fix (though I doubt it). The ubuntu-20.04 runners ship with v12.0.0.
Activity
2bndy5 commentedon Nov 5, 2022
We are still trying to understand why this is happening, but we are aware of this.
The only known workaround that we can recommend is to use the cpp-linter pkg manually via
and ensure the version of clang-tidy and/or clang-format is installed before using the
cpp-linterCLI.shenxianpeng commentedon Nov 5, 2022
Are you using the latest version of cpp-linter-action? Like v2 or v2.2.0
Could you please share your cpp-linter configuration here?
GewoonJaap commentedon Nov 5, 2022
Currently using @main, but V2 had the same issue. It's strange that one of my repos works fine with the linter while the other one gives this error.
Repo with error has a submodule to the repo thag works and just a hello world file, so nothing exciting there
GewoonJaap commentedon Nov 5, 2022
I will try that in a bit. Any chance you have a GitHub action file I can CTRL + C ;)
2bndy5 commentedon Nov 5, 2022
Its a bit old (untested for a few months), but it should still work with any runner on github: Try this code snippet in the README on master. You'll still have to tweak it for your project (obviously), but its a good start.
2bndy5 commentedon Nov 5, 2022
Keep in mind that the Ubuntu runner already comes with v12 of clang tools, so you may only need the stuff specific to
cpp-lintersteps.GewoonJaap commentedon Nov 5, 2022
Thanks! Will try that one out. Just thinking, could it have something to do with git submodules? Because the referenced .h file is only used in one of my submodules. I tried to ignore the entire folder, but it didn't help sadly..
2bndy5 commentedon Nov 5, 2022
Like I said we've looked into it and got stumped. This problem has been reported from repos that don't use submodules. Our test repo also uses a submodule, but any submodule's path is automatically ignored by cpp-linter. It wouldn't make sense to tell cpp-linter to analyze someone else's repo that your using in your repo, although it could be done with the
--ignoreoption.The problem that I see is that clang-tidy doesn't know where to find stddef.h when analyzing any header that includes it in the C std libs. The fact that this doesn't happen locally makes this problem hard to diagnose.
2bndy5 commentedon Nov 5, 2022
Its not specific to Ubuntu runners either. Windows runners show the problem too. It does seem to happen with clang-tidy-12 more than others, but it still does happen with other clang-tidy versions. My best guess is that the runner's C std lib is not the version that clang-tidy was built for (??) 🤷🏼
2bndy5 commentedon Nov 5, 2022
We could be a bit more helpful if the repo was public and you provided a link.
GewoonJaap commentedon Nov 5, 2022
Sadly the repo is private and I am unable to make it public
2bndy5 commentedon Nov 5, 2022
That's unfortunate here but understandable in the bigger picture.
shenxianpeng commentedon Nov 12, 2022
I think this issue should have been fixed in the latest release, #103 (comment)
If you could not provide your cpp-linter YAML config file, it's hard to tell what exactly the reason is.
shenxianpeng commentedon Nov 21, 2022
Please feel free to reopen if this problem still exists or you could provide your cpp-linter YAML config file.
ClemensLinnhoff commentedon Feb 3, 2023
I am having the same issue of
'stddef.h' file not foundin various files. You can check out this, where you will also find the yaml config file.2bndy5 commentedon Feb 3, 2023
This still eludes me... I think it has something to do with certain versions of clang-tidy and the installed C std libs. A while back, I found a stackoverflow suggestion that recommended using the C std lib from LLVM project (instead of the OS-specific PPA), but I don't think that solution is the right approach here.
ClemensLinnhoff commentedon Feb 6, 2023
@GewoonJaap did you find a fix for your private repository? Because with this error the cpp-linter is not really usable as it flags basically every file.
@2bndy5 Additionally we have other problems with the linter. Multiple header files are not found, although the compiler does not have a problem with it and we do a complete build within the pipeline, so that the compile_commands.json can be used. Probably in correlation with this error, some functions are marked as "can be made static" which are already declared static in the corresponding header file. So there seems to be a general problem with finding the correct headers. Do you have any idea how to fix this?
shenxianpeng commentedon Feb 6, 2023
From the output of the above problematic job, it looks like cpp-linter-action doesn't use native binaries.
Try adding
versionand setting it to'14'might fix'stddef.h' file not found2bndy5 commentedon Feb 6, 2023
TBH, our python script doesn't do anything special. It simply finds source files and feeds them to clang-format and/or clang-tidy. The problems you're reporting here sound more like problems with clang-tidy. Since I didn't author anything in the clang project, I can't confidently make any sound suggestions. It would be better to be able to reproduce this locally, but we've been unsuccessful on that front.
That said, have you tried using a different version of clang-tidy?
ubuntu-latest(currently Ubuntu-22.04) ships with v12, v13, and v14, so I'd recommend trying those because, as I said before, I think this problem is largely related to using certain versions of clang-tidy with certain version of the C/C++ std libs. It should be noted that each major version of the clang project isn't fully backward compatible, so the specified version is important.You're PR covers so many files, its not good to assume that the problems are related. In fact, this is the first I'm hearing about this error. My first impression makes me think there's a discrepancy between the implementation file and the header, but IDK.
We currently don't have a plan to support filtering the output captured from clang-tidy, and we cannot support using a special set of rules for certain files (which should be possible with multiple .clang-tidy config files).
Good catch @shenxianpeng ! If using the native v12 binary is desired, then the version option should specify
12.0.1which might include the a fix (though I doubt it). Theubuntu-20.04runners ship with v12.0.0.ClemensLinnhoff commentedon Feb 6, 2023
Specifying to use clang version 14 did fix the stddef.h error! Thank you for the suggestion!
The other errors remain, but I will try to replicate them offline.
2bndy5 commentedon Feb 6, 2023
I'm closing this. Its worth opening a new issue to track the "could be made static" problem.