【发布时间】:2020-04-22 20:12:24
【问题描述】:
嘿嘿。这是我在 Stackoverflow 上的第一篇文章。
我喜欢计算机编程,经过一些 Python 和 VBA 经验后,我正在尝试学习 C。 自从开始使用它以来,我使用 Visual Studio Code 进行培训,以便同时学习如何使用现代编程工具。
直到现在我都没有遇到任何问题,但现在我想编译多个文件。
当我尝试编译带有警告的文件时,终端会显示它
Executing task: C:/mingw-w64/mingw64/bin/gcc.exe -Wall -W -pedantic -ansi -std=c99 -O -g 'd:\OneDrive\Programmi\C\Kim_N_King-Programmazione_in_C\Capitolo 19\stackADT\stackclient.c' 'd:\OneDrive\Programmi\C\Kim_N_King-Programmazione_in_C\Capitolo 19\stackADT\stackADT3.c' -o 'd:\OneDrive\Programmi\C\Kim_N_King-Programmazione_in_C\Capitolo 19\stackADT\stackADT.exe'
d:\OneDrive\Programmi\C\Kim_N_King-Programmazione_in_C\Capitolo 19\stackADT\stackADT3.c: In function 'is_full':
d:\OneDrive\Programmi\C\Kim_N_King-Programmazione_in_C\Capitolo 19\stackADT\stackADT3.c:41:20: warning: unused parameter 's' [-Wunused-parameter]
bool is_full(Stack s) {
~~~~~~^
但在“问题”选项卡中未显示 (see the screenshot).
在只有 .c 文件可以编译的所有其他文件夹中,它可以完美运行。
以下是我的 jsons 文件,您可以从中轻松了解我的 VSC 配置和平台。
感谢您的阅读。
c_cpp_properties.json:
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"compilerPath": "C:/mingw-w64/mingw64/bin/gcc.exe",
"cStandard": "c99",
"cppStandard": "c++17",
"intelliSenseMode": "${default}"
}
],
"version": 4
}
launch.json:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "gcc.exe - Build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}\\stackADT.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "C:\\mingw-w64\\mingw64\\bin\\gdb.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "gcc.exe build active file"
}
]
}
tasks.json
{
"tasks": [
{
"type": "shell",
"label": "gcc.exe build active file",
"command": "C:/mingw-w64/mingw64/bin/gcc.exe",
"args": [
"-Wall",
"-W",
"-pedantic",
"-ansi",
"-std=c99",
"-O",
"-g",
"${file}",
"${fileDirname}\\stackADT3.c",
"-o",
"${fileDirname}\\stackADT.exe"
],
"options": {
"cwd": "C:/mingw-w64/mingw64/bin"
}
}
],
"version": "2.0.0"
}
【问题讨论】:
-
您的
task.json中没有定义问题匹配器。尝试"$gcc"预定义匹配器,但将其更改为使用绝对路径 stackoverflow.com/a/61314277/9938317 -
为什么在启动和任务文件中硬编码 .c 和 .exe 文件:为当前文件使用变量
标签: c visual-studio-code vscode-debugger