xmake
xmake copied to clipboard
Visual Studio C++ Modules Intellisense
Xmake Version
xmake v2.9.3+HEAD.a5da06f37
Operating System Version and Architecture
Windows 11 23H2
Describe Bug
The code compiles correctly, but IntelliSense cannot detect the modules available in the current project.
Expected Behavior
As shown in the image, the expected behavior is that IntelliSense should be able to detect the modules linked against the current library. However, in reality, it does not.
After some investigation, I managed to resolve this issue by uncommenting the project references located in the .vcxproj
file.
<ItemGroup>
<ProjectReference Include="..\mod\mod.vcxproj">
<Project>{2B32DA8B-CA39-4549-A720-EAEACE53D244}</Project>
</ProjectReference>
</ItemGroup>
Project Configuration
add_rules("mode.release", "mode.debug")
set_languages("c++20")
target("mod")
set_kind("static")
add_files("src/mod.ixx", {public = true})
add_files("src/mod.cpp")
target("hello")
set_kind("binary")
add_deps("mod")
add_files("src/main.cpp")
Additional Information and Error Logs
mod.ixx:
export module mod;
export namespace mod {
int foo();
}
mod.cpp:
module;
#include <iostream>
module mod;
namespace mod {
int foo() {
std::cout << "Hello World!\n";
return 2;
}
}
main.cpp:
import mod;
int main() {
return mod::foo();
}