【问题标题】:VSCode showing error while running C++ program on g++ compiler在 g++ 编译器上运行 C++ 程序时 VSCode 显示错误
【发布时间】:2021-05-03 10:05:05
【问题描述】:

我使用运行按钮在 VSCode 上运行了这个 C++ 程序 (Code on gfg),它以 code=1 退出并显示以下消息:

[Running] cd "c:\Users\pawar\OneDrive\Desktop\cp\" && g++ 5.cpp -o 5 && "c:\Users\pawar\OneDrive\Desktop\cp\"5
In file included from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\cassert:44:0,
                 from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\mingw32\bits\stdc++.h:33,
                 from 5.cpp:44:
c:\mingw\include\assert.h:38:38: error: conflicting declaration of C function 'void _assert(const char*, const char*, long long int)'
 _CRTIMP void __cdecl __MINGW_NOTHROW _assert (const char*, const char*, int) __MINGW_ATTRIB_NORETURN;
                                      ^~~~~~~
In file included from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\cassert:44:0,
                 from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\mingw32\bits\stdc++.h:33,
                 from 5.cpp:6:
c:\mingw\include\assert.h:38:38: note: previous declaration 'void _assert(const char*, const char*, int)'
 _CRTIMP void __cdecl __MINGW_NOTHROW _assert (const char*, const char*, int) __MINGW_ATTRIB_NORETURN;
[Done] exited with code=1 in 3.051 seconds

程序在 Codeforces 和 Codechef ide 上运行成功, 但没有在 Geeksforgeeks ide(SIGABRT 错误)和 VSCode 上运行。有人可以帮我解决这个问题,以便它在 VSCode 上运行,是否与使用的编译器有关,请指导?

【问题讨论】:

  • 你能提供一个minimal reproducible example吗?
  • #define int ll 这看起来有害。
  • 开发包下载了吗?
  • @PHD 是的,我经常使用 VSCode 来编译 C++,它从来没有出现过这样的错误。其他 C++ 程序编译没有任何问题。
  • @MikeCAT 我经常使用那条线,它工作正常。我尝试运行删除它的代码,但仍然无法正常工作。

标签: c++ visual-studio-code compiler-errors g++


【解决方案1】:

#include

此行包含两次,导致错误。

【讨论】:

猜你喜欢
  • 2018-05-12
  • 2019-05-31
  • 2022-11-08
  • 1970-01-01
  • 1970-01-01
  • 2019-05-30
  • 2019-02-21
  • 1970-01-01
  • 2016-07-09
相关资源
最近更新 更多