赞
踩
我要在vscode中写一些antlr代码生成的cpp代码,但是在引入头文件#include "antlr4-runtime.h"的时候,出现报错,显示没有这个头文件,显然这是我们没有导入相关的包,因此我首先尝试了将antlr4的依赖源码在visusal studio进行生成,然后产生了一个.lib文件,但是我在vs code中并没有找到可以将lib添加到环境中的设置,而在visual studio是可以这样做的。因此我换了一种方案
解决方案
点击设置
然后点击命令面板
在命令面板中搜索 c/c++ :编辑配置(json)
打开之后显示如下:
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"windowsSdkVersion": "10.0.19041.0",
"compilerPath": "cl.exe",
"cStandard": "c17",
"cppStandard": "c++17",
"intelliSenseMode": "windows-msvc-x64",
"browse": {
"path": [
"D:\\hu\\datadownload\\antlr4-cpp-runtime-4.13.1-source\\runtime\\bin\\vs-2019\\x64\\Debug DLL"
]
}
}
],
"version": 4
}
然后再includePath后面追加我们.h和cpp的文件夹路径
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**",
"D:\\hu\\datadownload\\antlr4-cpp-runtime-4.13.1-source\\runtime\\src"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"windowsSdkVersion": "10.0.19041.0",
"compilerPath": "cl.exe",
"cStandard": "c17",
"cppStandard": "c++17",
"intelliSenseMode": "windows-msvc-x64",
"browse": {
"path": [
"D:\\hu\\datadownload\\antlr4-cpp-runtime-4.13.1-source\\runtime\\bin\\vs-2019\\x64\\Debug DLL"
]
}
}
],
"version": 4
}
之后我们的头文件就不会报错了。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。