-
-
Notifications
You must be signed in to change notification settings - Fork 816
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
clangd error: unknown argument: '-imsvc' #6058
Comments
除了 win sdk,还有一些额外的内部头文件目录应该用哪个 flag 处理? |
In addition to win sdk, there are some additional internal header file directories which flag should be used to handle? |
https://clang.llvm.org/docs/UsersManual.html#windows-system-headers-and-library-lookup 看起来是输入 /external:xx 然后clang-cl内部转为-imsvc,但我不确定 |
https://clang.llvm.org/docs/UsersManual.html#windows-system-headers-and-library-lookup It looks like typing /external:xx then clang-cl internally translates to -imsvc, but I'm not sure |
可能直接判断工具链更好。 diff --git a/xmake/plugins/project/clang/compile_commands.lua b/xmake/plugins/project/clang/compile_commands.lua
index ad21cff51..16d185da2 100644
--- a/xmake/plugins/project/clang/compile_commands.lua
+++ b/xmake/plugins/project/clang/compile_commands.lua
@@ -58,12 +58,18 @@ end
-- specify windows sdk verison
function _get_windows_sdk_arguments(target)
local args = {}
- local msvc = target:toolchain("msvc")
+ local msvc = target:toolchain("msvc") or target:toolchain("clang") or target:toolchain("clang-cl")
if msvc then
local envs = msvc:runenvs()
if envs then
+ local include_sys_flag
+ if target:has_tool("cxx", "cl", "clang_cl") then
+ include_sys_dir_flag = "-imsvc"
+ else
+ include_sys_dir_flag = "-isystem"
+ end
for _, dir in ipairs(path.splitenv(envs.INCLUDE)) do
- table.insert(args, "-imsvc")
+ table.insert(args, include_sys_dir_flag)
table.insert(args, dir)
end
end
@waruqi 我发现 clang toolchian 永远取不到 runenvs,但三个 toolchain add vs env 代码都差不多的。 |
不一样,目前仅仅 msvc/clang-cl 会去检测加载默认的 msvc 环境,clang 不会,仅仅对 portable build tools 做了支持 另外, clang 是独立的工具链,也不应该跟 msvc 环境完全混在一起。 https://github.com/xmake-io/xmake/blob/dev/xmake/toolchains/clang/check.lua#L67 xmake/xmake/toolchains/clang-cl/check.lua Line 168 in 217d4ad
|
我的toolchain就是msvc,报错没有-imsvc,如果clangd用clang-cl来解析的话说明clang-cl也没有-imsvc。msvc里的system header用/external:I指定 |
https://reviews.llvm.org/D95472 根据这个链接可以用/winsdkdir和/winsdkversion指定sdk版本,我试了使用
"/winsdkdir", "C:\\Program Files (x86)\\Windows Kits\\10", "/winsdkversion", "10.0.22000.0"
可以,clangd不会报错。Originally posted by @xq114 in #3574 (comment)
The text was updated successfully, but these errors were encountered: