【问题标题】:I am new to programming and facing this issue with vs code [duplicate]我是编程新手,使用 vs 代码面临这个问题 [重复]
【发布时间】:2021-10-29 08:26:01
【问题描述】:

在 VS Code 上运行一个非常简单的程序时,我收到了 undefined reference to 'WinMain@16'
有人知道为什么我在 VS Code 的终端中运行它时会得到这个吗? 这是我的代码:

#include <stdio.h>
int main(){
    printf("hello");
    return 0;
}

这是我得到的错误:

[Running] cd "c:\vs\c cource with notes\Chapter 1\" && gcc mypractice.c -o mypractice && "c:\vs\c cource with notes\Chapter 1\"mypractice
C:/Program Files (x86)/mingw-w64/i686-8.1.0-posix-dwarf-rt_v6-rev0/mingw32/bin/../lib/gcc/i686-w64-mingw32/8.1.0/../../../../i686-w64-mingw32/lib/../lib/libmingw32.a(lib32_libmingw32_a-crt0_c.o):crt0_c.c:(.text.startup+0x39): undefined reference to 'WinMain@16'
collect2.exe: error: ld returned 1 exit status*
[Done] exited with code=1 in 0.809 seconds

【问题讨论】:

  • 你的错误信息被剪掉了,能完整显示吗?也请阅读Why not upload images of code/errors when asking a question?
  • 我们能看到完整的错误信息吗? (两条灰线)。编辑您的问题并复制粘贴。
  • 不,我已经上传了完整的图片。
  • @Gaurav,不,你不是,检查第一条灰线,它在你的图像中不完整。请将两条灰线复制粘贴到您的问题中。
  • 好的,先生,我重新上传图片

标签: c visual-studio-code vscode-settings


【解决方案1】:

您的程序未检测到main() 函数。你在执行之前保存了文件吗?尝试保存并重新执行。
您还应该开始做好制表工作。 printf 行没有很好地制表。

【讨论】:

    猜你喜欢
    • 2020-07-25
    • 1970-01-01
    • 1970-01-01
    • 2021-05-25
    • 1970-01-01
    • 1970-01-01
    • 2017-02-07
    • 1970-01-01
    • 2020-04-15
    相关资源
    最近更新 更多