Skip to content
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

mfc的compile_commands生成有缺少,clangd找不到#include <afxwin.h> #6038

Closed
thexin7 opened this issue Jan 4, 2025 · 3 comments
Closed
Labels
Milestone

Comments

@thexin7
Copy link

thexin7 commented Jan 4, 2025

Xmake 版本

xmake v2.9.7+master.b029e65ed

操作系统版本和架构

windows 11

描述问题

想使用xmake编译mfc项目,创建一个简单的mfc对话框。
编译项目后,生成的 compile_commands并没有包含atlmfc,导致clangd找不到mfc的基础头文件
image

添加指定的atlmfc目录后,生成的compile_commands包含atlmfc,使得clangd能找到
65033b002d5a103d1fc4179d08ffa84

期待的结果

补充compile_commands中对mfc的支持

工程配置

target("MemoryTraversal")
    add_rules("win.sdk.mfc.static_app")
    set_kind("binary")
    add_files("src/*.cpp")
    add_files("resource/*.rc")
    add_includedirs("src", "resource")
    add_deps("PluginManager")    add_deps("PluginManager")
target_end()

附加信息和错误日志

不补充include目录生成出的compile_commands

{
  "directory": "e:\\Project\\KernelDrivers",
  "arguments": ["C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.42.34433\\bin\\HostX64\\x64\\cl.exe", "/c", "/nologo", "/W4", "/O2", "/std:c++20", "/IMemoryTraversal\\src", "/IMemoryTraversal\\resource", "/DUNICODE", "/D_UNICODE", "/DCONTEXT_LOG", "/EHsc", "/utf-8", "/MT", "/DNDEBUG", "/Fobuild\\.objs\\MemoryTraversal\\windows\\x64\\release\\MemoryTraversal\\src\\main.cpp.obj", "MemoryTraversal\\src\\main.cpp", "-imsvc", "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.22621.0\\cppwinrt", "-imsvc", "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.22621.0\\km", "-imsvc", "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.22621.0\\shared", "-imsvc", "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.22621.0\\ucrt", "-imsvc", "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.22621.0\\um", "-imsvc", "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.22621.0\\winrt", "-imsvc", "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.42.34433\\include"],
  "file": "MemoryTraversal\\src\\main.cpp"
},
{
  "directory": "e:\\Project\\KernelDrivers",
  "arguments": ["C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.42.34433\\bin\\HostX64\\x64\\cl.exe", "/c", "/nologo", "/W4", "/O2", "/std:c++20", "/IMemoryTraversal\\src", "/IMemoryTraversal\\resource", "/DUNICODE", "/D_UNICODE", "/DCONTEXT_LOG", "/EHsc", "/utf-8", "/MT", "/DNDEBUG", "/Fobuild\\.objs\\MemoryTraversal\\windows\\x64\\release\\MemoryTraversal\\src\\MainDialog.cpp.obj", "MemoryTraversal\\src\\MainDialog.cpp", "-imsvc", "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.22621.0\\cppwinrt", "-imsvc", "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.22621.0\\km", "-imsvc", "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.22621.0\\shared", "-imsvc", "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.22621.0\\ucrt", "-imsvc", "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.22621.0\\um", "-imsvc", "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.22621.0\\winrt", "-imsvc", "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.42.34433\\include"],
  "file": "MemoryTraversal\\src\\MainDialog.cpp"
}

补充include:

    add_includedirs("C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.42.34433\\atlmfc\\include")

结果

{
  "directory": "e:\\Project\\KernelDrivers",
  "arguments": ["C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.42.34433\\bin\\HostX64\\x64\\cl.exe", "/c", "/nologo", "/W4", "/O2", "/std:c++20", "/IMemoryTraversal\\src", "/IMemoryTraversal\\resource", "/IC:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.42.34433\\atlmfc\\include", "/DUNICODE", "/D_UNICODE", "/DCONTEXT_LOG", "/DAFX", "/D_AFXDLL", "/EHsc", "/utf-8", "/MD", "/DNDEBUG", "/Fobuild\\.objs\\MemoryTraversal\\windows\\x64\\release\\MemoryTraversal\\src\\main.cpp.obj", "MemoryTraversal\\src\\main.cpp", "-imsvc", "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.22621.0\\cppwinrt", "-imsvc", "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.22621.0\\km", "-imsvc", "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.22621.0\\shared", "-imsvc", "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.22621.0\\ucrt", "-imsvc", "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.22621.0\\um", "-imsvc", "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.22621.0\\winrt", "-imsvc", "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.42.34433\\include"],
  "file": "MemoryTraversal\\src\\main.cpp"
},
{
  "directory": "e:\\Project\\KernelDrivers",
  "arguments": ["C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.42.34433\\bin\\HostX64\\x64\\cl.exe", "/c", "/nologo", "/W4", "/O2", "/std:c++20", "/IMemoryTraversal\\src", "/IMemoryTraversal\\resource", "/IC:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.42.34433\\atlmfc\\include", "/DUNICODE", "/D_UNICODE", "/DCONTEXT_LOG", "/DAFX", "/D_AFXDLL", "/EHsc", "/utf-8", "/MD", "/DNDEBUG", "/Fobuild\\.objs\\MemoryTraversal\\windows\\x64\\release\\MemoryTraversal\\src\\MainDialog.cpp.obj", "MemoryTraversal\\src\\MainDialog.cpp", "-imsvc", "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.22621.0\\cppwinrt", "-imsvc", "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.22621.0\\km", "-imsvc", "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.22621.0\\shared", "-imsvc", "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.22621.0\\ucrt", "-imsvc", "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.22621.0\\um", "-imsvc", "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.22621.0\\winrt", "-imsvc", "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.42.34433\\include"],
  "file": "MemoryTraversal\\src\\MainDialog.cpp"
},
@thexin7 thexin7 added the bug label Jan 4, 2025
@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


Title: The compile_commands generation of mfc is missing, clangd cannot find #include <afxwin.h>

@star-hengxing
Copy link
Contributor

Try it again xmake update -s github:star-hengxing/xmake#cdb

@thexin7
Copy link
Author

thexin7 commented Jan 4, 2025

thx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants