【发布时间】:2020-07-23 23:38:02
【问题描述】:
所以我正在制作一个示例程序来学习如何在 Visual Studio Code 中构建和调试 C 项目。作为参考,这是我的项目的launch.json 和tasks.json:
launch.json:
"version": "0.2.0",
"configurations": [
{
"name": "test-project",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}\\test.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "C:\\MinGW\\bin\\gdb.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "build test-project"
}
]
tasks.json:
"version": "2.0.0",
"tasks": [
{
"label": "build test-project",
"type": "shell",
"command": "gcc",
"args": [
"-std=c99",
"-g",
"${workspaceFolder}\\test.c",
"-o",
"${workspaceRoot}\\test.exe"
],
"group": {
"kind": "build",
"isDefault": true
}
}
]
这里是“test.c”:
test.c
#include <stdio.h>
int main(int argc, char* argv[]){
int t = 9;
int p = 10;
return 0;
}
这是我在命令行参数中看到的,即使我没有提供命令行参数:
正如您在监视面板中看到的那样,有 3 个额外的命令行参数 "2>CON"、"1>CON" 和 "<CON"。为什么即使我提供了 0 个命令行参数也会发生这种情况?
【问题讨论】:
-
这些看起来像是文件描述符的重定向。
2>CON将 stderr 重定向到 CON,1>CON将 stdout 重定向到 CON,<CON将 stdin 从 CON 重定向。看起来有些东西正在将这些添加到argv。
标签: c visual-studio gcc