clangTidy linting corecrt_wstdio.h
Posted
技术标签:
【中文标题】clangTidy linting corecrt_wstdio.h【英文标题】: 【发布时间】:2017-11-29 02:34:03 【问题描述】:我正在尝试在遗留代码库上使用 clangTidy。在一个文件上尝试最简单的测试用例时,我遇到了这个我不知道如何防止的错误。我相信这来自我的文件,包括 StdAfx,其中包括一些标准头文件,它们以某种方式被 linted?我已经删除了一些冗长的行...有什么想法吗?
我正在使用 Clang Power Tools 来调用它,但我认为无论如何结果都是一样的。
Start Clang Tidy
VERBOSE: clang-build.ps1 invocation args:
aVcxprojToCompile = C:\Dev\Projects\myProject\Src\Foo\PROJECT.vcxproj
aCppToCompile = Checksum.cpp
aVcxprojConfigPlatform = Debug|x64
aClangCompileFlags = -Werror -std=c++14 -Wall -fms-compatibility-version=19.10 -fms-compatibility -Wmicrosoft
-Wno-invalid-token-paste -Wno-unknown-pragmas -Wno-unused-variable -Wno-unused-value
Verbose = True
aTidyFixFlags = -*,modernize-use-equals-default,modernize-use-equals-delete
aVisualStudioVersion = 2015
aVisualStudiosku = Professional
aDirectory = C:\Dev\Projects\myProject\Src
aDisableNameRegexMatching = True
VERBOSE: Clang job tool: clang-tidy.exe
VERBOSE: Clang job args[0]: "C:\Dev\Projects\myProject\Src\Foo\Common\Checksum.cpp"
-checks=-*,modernize-use-equals-default,modernize-use-equals-delete
-header-filter="C:\\Dev\\Projects\\myProject\\Src" -quiet -fix-errors -- -Werror -std=c++14 -Wall
-fms-compatibility-version=19.10 -fms-compatibility -Wmicrosoft -Wno-invalid-token-paste -Wno-unknown-pragmas
-Wno-unused-variable -Wno-unused-value -D_FooDLL -DZLIB_DLL -D_DEBUG -D_ITERATOR_DEBUG_LEVEL=1 -D_DLL -D_USRDLL
-DNOMINMAX -DWIN32 -D_WINDOWS -DVL_STATIC_LINKING -D_BIND_TO_CURRENT_VCLIBS_VERSION -D_MT -DSS_NO_CONVERSION
-D_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES=1 -DUNICODE -D_UNICODE
1: C:\Dev\Projects\myProject\Src\Foo\Common\Checksum.cpp
49 warnings and 3 errors generated.
Error while processing
C:\Dev\Projects\myProject\Src\Foo\Common\Checksum.cpp.
C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\corecrt_wstdio.h(1488): error: inline declaration of '__vswprintf_l' not allowed in block scope [clang-diagnostic-error]
int, __RETURN_POLICY_SAME, _CRT_STDIO_INLINE, __CRTDECL, __swprintf_l, __vswprintf_l, _vswprintf_s_l,
^
C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\corecrt_stdio_config.h(21): message: expanded from macro '_CRT_STDIO_INLINE'
#define _CRT_STDIO_INLINE __inline
^
C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\corecrt_wstdio.h(1497): error: inline declaration of '_vswprintf' not allowed in block scope [clang-diagnostic-error]
int, __RETURN_POLICY_SAME, _CRT_STDIO_INLINE, __CRTDECL, _swprintf, _swprintf_s, _vswprintf, vswprintf_s,
^
C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\corecrt_stdio_config.h(21): message: expanded from macro '_CRT_STDIO_INLINE'
#define _CRT_STDIO_INLINE __inline
Done Clang Tidy
【问题讨论】:
【参考方案1】:定义这个宏解决了这个问题:-D _NO_CRT_STDIO_INLINE
只需将其添加到 clang 的参数中
【讨论】:
以上是关于clangTidy linting corecrt_wstdio.h的主要内容,如果未能解决你的问题,请参考以下文章
找不到 corecrt.h:$(UniversalCRT_IncludePath) 错误
Microsoft Visual Studio Community 2019:致命错误 C1083:无法打开包含文件:'corecrt.h':没有这样的文件或目录
VS 2015 C++ Cannot find corecrt.h and cannot open file ‘ucrtd.lib‘
在 gradle 同步时面临问题 - 找不到 lint-gradle-api.jar (com.android.tools.lint:lint-gradle-api:26.1.2)