我正在使用 VS Code 版本 1.62.0(用户设置)
我正在尝试在 C (test.c) 中运行一个基本程序:
#include <stdio.h>
#include <stdlib.h>
int main() {
printf("Hello");
return 0;
}
我试图通过单击播放符号 (CTRL+ALT+N) 来运行,但它在终端中变成这样:
PS C:\Users\X\Dropbox\My PC_X\Downloads> cd "c:\Users\X\Dropbox\My PC_X\Downloads\est\" ; if ($?) { g++ test.c *.c -o test } ; if ($?) { .\test }
C:\Users\X\AppData\Local\Temp\ccyBS6yO.o:test.c:(.text+0x0): multiple definition of `main'
C:\Users\X\AppData\Local\Temp\ccwvYj0K.o:test.c:(.text+0x0): first defined here
collect2.exe: error: ld returned 1 exit status
我不知道这些信息是否有帮助。供您参考,我使用的是 Windows 11(在我的情况下,我认为它真的坏了)。以前,我将 [桌面、文档、图片] 与 OneDrive 同步(OneDrive 成为我的本地文件夹)。但是前两天,我关闭了 Documents 的同步,一些文件完全在 OneDrive 中(不一定在我的本地文件夹中)[为了更清楚,看图]
这是我的 gcc 版本:
gcc.exe (MinGW.org GCC-6.3.0-1) 6.3.0
Copyright (C) 2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
这是我的task.json:
{
"version": "2.0.0",
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: gcc.exe build active file",
"command": "C:\\MinGW\\bin\\gcc.exe",
"args": [
"-fdiagnostics-color=always",
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": "build",
"detail": "compiler: C:\\MinGW\\bin\\gcc.exe"
}
]
}