以VScode配置arduino文件为例,若arduino文件出现报错,那么code是一定会有问题的
当arduino如上图显示正常加载无报错时,此时VScode程序报错,总显示Exit with code=1,若根据code的报错提示找不出报错原因的话,我们可以不影响工作区程序去修改原配置文件
下面是 程序的arduino.json文件
下面为takes.json文件的代码
{
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: gcc.exe 生成活动文件",
"command": "C:\\msys32\\mingw32\\bin\\gcc.exe",
"args": [
"-fdiagnostics-color=always",
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "调试器生成的任务。"
}
],
"version": "2.0.0"
}
settings.json文件代码如下
{
"C_Cpp.dimInactiveRegions": false,
"files.associations": {
"iostream": "cpp",
"tuple": "cpp",
"stack": "cpp",
"string": "cpp",
"ostream": "cpp",
"ios": "cpp",
"istream": "cpp",
"vector": "cpp",
"fstream": "cpp",
"cmath": "cpp"
},
"C_Cpp_Runner.msvcBatchPath": "",
"C_Cpp_Runner.cCompilerPath": "c:/msys32/mingw32/bin/gcc.exe",
"C_Cpp_Runner.cppCompilerPath": "g++",
"C_Cpp_Runner.debuggerPath": "gdb",
"C_Cpp_Runner.cStandard": "",
"C_Cpp_Runner.cppStandard": "",
"C_Cpp_Runner.useMsvc": false,
"C_Cpp_Runner.warnings": [
"-Wall",
"-Wextra",
"-Wpedantic",
"-Wshadow",
"-Wformat=2",
"-Wconversion",
"-Wnull-dereference",
"-Wsign-conversion"
],
"C_Cpp_Runner.enableWarnings": true,
"C_Cpp_Runner.warningsAsError": false,
"C_Cpp_Runner.compilerArgs": [],
"C_Cpp_Runner.linkerArgs": [],
"C_Cpp_Runner.includePaths": [],
"C_Cpp_Runner.includeSearch": [
"*",
"**/*"
],
"C_Cpp_Runner.excludeSearch": [
"**/build",
"**/build/**",
"**/.*",
"**/.*/**",
"**/.vscode",
"**/.vscode/**"
],
"C_Cpp.errorSquiggles": "disabled"
}
//其中mingw32\\bin\\gcc.exe文件根据自己的路径修改(一般都在C盘c:/msys32/mingw32/bin/gcc.exe)
确保不会在发生报错,最好在设置里关闭自动更新版本。
解决Exit with code=1的问题,(确保无中文路径)