Cppcheck cannot find include files, presumably when there's a environment variable in the includepath.
s7jones opened this issue · 7 comments
Error Message:
Starting analyzer with arguments: --inline-suppr -v --template="{file}|{line}|{severity}|{id}|{message}" --library=windows --library=std --language=c++ --enable=style,information,warning,performance,portability --relative-paths="C:\Users\Sam\Documents\Visual Studio 2013\Projects\PeregrineBot\PeregrineBot" -j 4 --suppress=unmatchedSuppression --suppress=*:*RectangleArray.h --suppress=*:*UnitType.h --suppress=*:*UnaryFilter.h --suppress=*:*ComparisonFilter.h --suppress=*:*UnitSizeType.h --suppress=*:*UpgradeType.h --suppress=*:*WeaponType.h --suppress=*:*Order.h --suppress=*:*Race.h --suppress=*:*BulletType.h --suppress=*:*Color.h --suppress=*:*DamageType.h --suppress=*:*Error.h --suppress=*:*ExplosionType.h --suppress=*:*GameType.h --suppress=*:*PlayerType.h --suppress=*:*TechType.h --suppress=*:*BestFilter.h --suppress=*:*Position.h --suppress=*:*UnitCommandType.h -I"C:\dev\bwapi\Release_Binary\include" -I"C:\dev\bwta2\include" -I"C:\Users\Sam\Documents\Visual Studio 2013\Projects\PeregrineBot\PeregrineBot\%BWAPI_DIR%\include" -I"C:\Users\Sam\Documents\Visual Studio 2013\Projects\PeregrineBot\PeregrineBot\%BWTA_DIR%\include" -I"C:\Users\Sam\Documents\Visual Studio 2013\Projects\PeregrineBot\PeregrineBot\Include\um" -I"C:\Users\Sam\Documents\Visual Studio 2013\Projects\PeregrineBot\PeregrineBot" --file-list="C:\Users\Sam\AppData\Local\Temp\CPPCheckPlugin_i1hfjavc.n1n" --force
(information) Couldn't find path given by -I 'C:\Users\Sam\Documents\Visual Studio 2013\Projects\PeregrineBot\PeregrineBot\%BWAPI_DIR%\include\'
(information) Couldn't find path given by -I 'C:\Users\Sam\Documents\Visual Studio 2013\Projects\PeregrineBot\PeregrineBot\%BWTA_DIR%\include\'
(information) Couldn't find path given by -I 'C:\Users\Sam\Documents\Visual Studio 2013\Projects\PeregrineBot\PeregrineBot\Include\um\'
In my vcxproj:
<IncludePath>%BWAPI_DIR%\include;%BWTA_DIR%\include;$(IncludePath)</IncludePath>
....
<AdditionalIncludeDirectories>$(BWAPI_DIR)\include;$(BWTA_DIR)\include;$(SQLITE_DIR);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
It looks like cppcheck is not resolving the environment variables. Thanks.
Apparently, the include paths that the add-in queries from Visual Studio are not resolved for us by Visual Studio (that would be too easy and no fun at all, right?).
Simply finding and resolving envvars is trivial, perhaps a bit less trivial is to remember to check and take into account the "Environment" setting of the corresponding project.
On a second thought, after spending half the evening trying to access the Debug -> Environment property, I realized it probably doesn't affect the include paths and other compilation settings.
Fixed. You can install the updated add-in from the Appveyor build artifacts: https://ci.appveyor.com/project/VioletGiraffe/cppcheck-vs-addin/build/artifacts
Could you also expand environment variables in suppression settings?
Why would you use variables there? Can you give me an example?
I tried ignoring %BWAPI_DIR%/**/*
, because I don't want to run cppcheck on the includes from that project.