求解:M1 Mac下VS Code编译器调试含输入的C程序出错
当我打上断点,想调试下面这串代码
#include <stdio.h>
#define ull unsigned long long
ull jie (ull n){
if (n<=1) return 1;
else return n*jie(n-1);
}
int main()
{
int n;ull S=0ull;
scanf("%d",&n);
for (int i = 1; i <= n; i++) S+=jie(i);
printf("%llu\n",S);
return 0;
}
按F5调试的时候发现在调试控制台里无法输入,提示:Unable to perform this action because the process is running. 即使是把launch.json里面的配置改成如下也不行:
"name": "gcc - 生成和调试活动文件",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}/${fileBasenameNoExtension}",
"args": [],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": true,
"MIMode": "lldb",
"preLaunchTask": "C/C++: gcc 生成活动文件"
tasks.json的配置如下:
{
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: gcc 生成活动文件",
"command": "/opt/homebrew/Cellar/gcc/12.2.0/bin/gcc-12",
"args": [
"-fdiagnostics-color=always",
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "调试器生成的任务。"
}
],
"version": "2.0.0"
}