【发布时间】:2020-02-20 11:56:12
【问题描述】:
我想知道 clang 如何在 Windows 系统上工作。
我按照this website 上的教程学习并成功构建了二进制文件。
这是我的问题。
当我以调试模式构建项目时,它会生成 .exe、.pdb、.ilk。
调试也可以正常工作,但是当我介入某些功能(例如:std::vector::push_back)时,它会在 VisualStudio 上找到矢量源文件。
我认为,它应该没有找到源文件,因为 push_back 的实现应该属于 libclang。
为什么会这样?
测试代码如下
auto answer = [](int n)
{
return 32 + n;
};
constexpr int response = answer(10);
构建命令是
C:/Program Files/LLVM/bin/clang++.exe' -std=c++2a ./example_1.cpp -o example_1.exe --debug
仅供参考我的系统有 VisualStudio 2015 和 LLVM 9.0。 vs代码配置是
/* c_cpp_properties.json */
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**",
"C:/Program Files/LLVM/include/llvm-c",
"C:/Program Files/LLVM/include/clang-c"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"windowsSdkVersion": "8.1",
"compilerPath": "\"C:/Program Files/LLVM/bin/clang++.exe\"",
"cStandard": "c11",
"cppStandard": "c++20",
"intelliSenseMode": "clang-x64"
}
],
"version": 4
}
/* launch.json */
{
"version": "0.2.0",
"configurations": [
{
"name": "(Windows) Launch",
"type": "cppvsdbg",
"request": "launch",
"program": "${workspaceFolder}/example_1.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true
}
]
}
}
/* tasks.json */
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "clang++.exe build active file",
"command": "C:/Program Files/LLVM/bin/clang++.exe",
"args": [
"-std=c++2a",
"./example_1.cpp",
"-o",
"example_1.exe",
"--debug"
],
"group": "build"
}
]
}
【问题讨论】: