当前位置: 首页 > 知识库问答 >
问题:

如何使g++需要一个标准的'main'?

钦良弼
2023-03-14
main(){}
[C:\my\temp]
> g++ --version | find "++"
g++ (i686-win32-dwarf-rev1, Built by MinGW-W64 project) 6.2.0

[C:\my\temp]
> type foo.cpp
main() {}

[C:\my\temp]
> dir /b
foo.cpp

[C:\my\temp]
> g++ foo.cpp -Wall -Wextra -Wreturn-type -pedantic

[C:\my\temp]
> dir /b
a.exe
foo.cpp

[C:\my\temp]
> _
C:\my\temp]
> g++ -v --version
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=C:/Program\ Files\ (x86)/mingw-w64/i686-6.2.0-win32-dwarf-rt_v5-rev1/mingw32/bin/../libexec/gcc/i686-w64-mingw32/6.2.0/lto-wrapper.exe
g++ (i686-win32-dwarf-rev1, Built by MinGW-W64 project) 6.2.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.


Target: i686-w64-mingw32
Configured with: ../../../src/gcc-6.2.0/configure --host=i686-w64-mingw32 --build=i686-w64-mingw32 --target=i686-w64-mingw32 --prefix=/mingw32 --with-sysroot=/c/mingw620/i686-620-win32-dwarf-rt_v5-rev1/mingw32 --enable-shared --enable-static --disable-multilib --enable-languages=c,c++,fortran,lto --enable-libstdcxx-time=yes --enable-threads=win32 --enable-libgomp --enable-libatomic --enable-lto --enable-graphite --enable-checking=release --enable-fully-dynamic-string --enable-version-specific-runtime-libs --enable-libstdcxx-filesystem-ts=yes --disable-sjlj-exceptions --with-dwarf2 --disable-isl-version-check --disable-libstdcxx-pch --disable-libstdcxx-debug --enable-bootstrap --disable-rpath --disable-win32-registry --disable-nls --disable-werror --disable-symvers --with-gnu-as --with-gnu-ld --with-arch=i686 --with-tune=generic --with-libiconv --with-system-zlib --with-gmp=/c/mingw620/prerequisites/i686-w64-mingw32-static --with-mpfr=/c/mingw620/prerequisites/i686-w64-mingw32-static --with-mpc=/c/mingw620/prerequisites/i686-w64-mingw32-static --with-isl=/c/mingw620/prerequisites/i686-w64-mingw32-static --with-pkgversion='i686-win32-dwarf-rev1, Built by MinGW-W64 project' --with-bugurl=http://sourceforge.net/projects/mingw-w64 CFLAGS='-O2 -pipe -I/c/mingw620/i686-620-win32-dwarf-rt_v5-rev1/mingw32/opt/include -I/c/mingw620/prerequisites/i686-zlib-static/include -I/c/mingw620/prerequisites/i686-w64-mingw32-static/include' CXXFLAGS='-O2 -pipe -I/c/mingw620/i686-620-win32-dwarf-rt_v5-rev1/mingw32/opt/include -I/c/mingw620/prerequisites/i686-zlib-static/include -I/c/mingw620/prerequisites/i686-w64-mingw32-static/include' CPPFLAGS= LDFLAGS='-pipe -L/c/mingw620/i686-620-win32-dwarf-rt_v5-rev1/mingw32/opt/lib -L/c/mingw620/prerequisites/i686-zlib-static/lib -L/c/mingw620/prerequisites/i686-w64-mingw32-static/lib -Wl,--large-address-aware'
Thread model: win32
gcc version 6.2.0 (i686-win32-dwarf-rev1, Built by MinGW-W64 project)
COLLECT_GCC_OPTIONS='-v' '--version' '-shared-libgcc' '-mtune=generic' '-march=i686'
 C:/Program Files (x86)/mingw-w64/i686-6.2.0-win32-dwarf-rt_v5-rev1/mingw32/bin/../libexec/gcc/i686-w64-mingw32/6.2.0/cc1.exe -quiet -v -iprefix C:/Program Files (x86)/mingw-w64/i686-6.2.0-win32-dwarf-rt_v5-rev1/mingw32/bin/../lib/gcc/i686-w64-mingw32/6.2.0/ -U_REENTRANT help-dummy -quiet -dumpbase help-dummy -mtune=generic -march=i686 -auxbase help-dummy -version --version -o C:\Users\AlfP\AppData\Local\Temp\cc4K0l79.s
GNU C11 (i686-win32-dwarf-rev1, Built by MinGW-W64 project) version 6.2.0 (i686-w64-mingw32)
        compiled by GNU C version 6.2.0, GMP version 6.1.0, MPFR version 3.1.4, MPC version 1.0.3, isl version 0.15
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
COLLECT_GCC_OPTIONS='-v' '--version' '-shared-libgcc' '-mtune=generic' '-march=i686'
 C:/Program Files (x86)/mingw-w64/i686-6.2.0-win32-dwarf-rt_v5-rev1/mingw32/bin/../lib/gcc/i686-w64-mingw32/6.2.0/../../../../i686-w64-mingw32/bin/as.exe -v --version -o C:\Users\AlfP\AppData\Local\Temp\ccn2QnTg.o C:\Users\AlfP\AppData\Local\Temp\cc4K0l79.s
GNU assembler version 2.25 (i686-w64-mingw32) using BFD version (GNU Binutils) 2.25
GNU assembler (GNU Binutils) 2.25
Copyright (C) 2014 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or later.
This program has absolutely no warranty.
This assembler was configured for a target of `i686-w64-mingw32'.
COMPILER_PATH=C:/Program Files (x86)/mingw-w64/i686-6.2.0-win32-dwarf-rt_v5-rev1/mingw32/bin/../libexec/gcc/i686-w64-mingw32/6.2.0/;C:/Program Files (x86)/mingw-w64/i686-6.2.0-win32-dwarf-rt_v5-rev1/mingw32/bin/../libexec/gcc/;C:/Program Files (x86)/mingw-w64/i686-6.2.0-win32-dwarf-rt_v5-rev1/mingw32/bin/../lib/gcc/i686-w64-mingw32/6.2.0/../../../../i686-w64-mingw32/bin/
LIBRARY_PATH=C:/Program Files (x86)/mingw-w64/i686-6.2.0-win32-dwarf-rt_v5-rev1/mingw32/bin/../lib/gcc/i686-w64-mingw32/6.2.0/;C:/Program Files (x86)/mingw-w64/i686-6.2.0-win32-dwarf-rt_v5-rev1/mingw32/bin/../lib/gcc/;C:/Program Files (x86)/mingw-w64/i686-6.2.0-win32-dwarf-rt_v5-rev1/mingw32/bin/../lib/gcc/i686-w64-mingw32/6.2.0/../../../../i686-w64-mingw32/lib/../lib/;C:/Program Files (x86)/mingw-w64/i686-6.2.0-win32-dwarf-rt_v5-rev1/mingw32/bin/../lib/gcc/i686-w64-mingw32/6.2.0/../../../../lib/;C:/Program Files (x86)/mingw-w64/i686-6.2.0-win32-dwarf-rt_v5-rev1/mingw32/bin/../lib/gcc/i686-w64-mingw32/6.2.0/../../../../i686-w64-mingw32/lib/;C:/Program Files (x86)/mingw-w64/i686-6.2.0-win32-dwarf-rt_v5-rev1/mingw32/bin/../lib/gcc/i686-w64-mingw32/6.2.0/../../../
COLLECT_GCC_OPTIONS='-v' '--version' '-shared-libgcc' '-mtune=generic' '-march=i686'
 C:/Program Files (x86)/mingw-w64/i686-6.2.0-win32-dwarf-rt_v5-rev1/mingw32/bin/../libexec/gcc/i686-w64-mingw32/6.2.0/collect2.exe -plugin C:/Program Files (x86)/mingw-w64/i686-6.2.0-win32-dwarf-rt_v5-rev1/mingw32/bin/../libexec/gcc/i686-w64-mingw32/6.2.0/liblto_plugin-0.dll -plugin-opt=C:/Program Files (x86)/mingw-w64/i686-6.2.0-win32-dwarf-rt_v5-rev1/mingw32/bin/../libexec/gcc/i686-w64-mingw32/6.2.0/lto-wrapper.exe -plugin-opt=-fresolution=C:\Users\AlfP\AppData\Local\Temp\ccXVaxln.res -plugin-opt=-pass-through=-lmingw32 -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lmoldname -plugin-opt=-pass-through=-lmingwex -plugin-opt=-pass-through=-lmsvcrt -plugin-opt=-pass-through=-ladvapi32 -plugin-opt=-pass-through=-lshell32 -plugin-opt=-pass-through=-luser32 -plugin-opt=-pass-through=-lkernel32 -plugin-opt=-pass-through=-liconv -plugin-opt=-pass-through=-lmingw32 -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lmoldname -plugin-opt=-pass-through=-lmingwex -plugin-opt=-pass-through=-lmsvcrt --sysroot=C:/mingw620/i686-620-win32-dwarf-rt_v5-rev1/mingw32 -m i386pe -Bdynamic -u ___register_frame_info -u ___deregister_frame_info --version C:/Program Files (x86)/mingw-w64/i686-6.2.0-win32-dwarf-rt_v5-rev1/mingw32/bin/../lib/gcc/i686-w64-mingw32/6.2.0/../../../../i686-w64-mingw32/lib/../lib/crt2.o C:/Program Files (x86)/mingw-w64/i686-6.2.0-win32-dwarf-rt_v5-rev1/mingw32/bin/../lib/gcc/i686-w64-mingw32/6.2.0/crtbegin.o -LC:/Program Files (x86)/mingw-w64/i686-6.2.0-win32-dwarf-rt_v5-rev1/mingw32/bin/../lib/gcc/i686-w64-mingw32/6.2.0 -LC:/Program Files (x86)/mingw-w64/i686-6.2.0-win32-dwarf-rt_v5-rev1/mingw32/bin/../lib/gcc -LC:/Program Files (x86)/mingw-w64/i686-6.2.0-win32-dwarf-rt_v5-rev1/mingw32/bin/../lib/gcc/i686-w64-mingw32/6.2.0/../../../../i686-w64-mingw32/lib/../lib -LC:/Program Files (x86)/mingw-w64/i686-6.2.0-win32-dwarf-rt_v5-rev1/mingw32/bin/../lib/gcc/i686-w64-mingw32/6.2.0/../../../../lib -LC:/Program Files (x86)/mingw-w64/i686-6.2.0-win32-dwarf-rt_v5-rev1/mingw32/bin/../lib/gcc/i686-w64-mingw32/6.2.0/../../../../i686-w64-mingw32/lib -LC:/Program Files (x86)/mingw-w64/i686-6.2.0-win32-dwarf-rt_v5-rev1/mingw32/bin/../lib/gcc/i686-w64-mingw32/6.2.0/../../.. C:\Users\AlfP\AppData\Local\Temp\ccn2QnTg.o -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcrt -ladvapi32 -lshell32 -luser32 -lkernel32 -liconv -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcrt C:/Program Files (x86)/mingw-w64/i686-6.2.0-win32-dwarf-rt_v5-rev1/mingw32/bin/../lib/gcc/i686-w64-mingw32/6.2.0/crtend.o
collect2 version 6.2.0
C:/Program Files (x86)/mingw-w64/i686-6.2.0-win32-dwarf-rt_v5-rev1/mingw32/bin/../lib/gcc/i686-w64-mingw32/6.2.0/../../../../i686-w64-mingw32/bin/ld.exe -plugin C:/Program Files (x86)/mingw-w64/i686-6.2.0-win32-dwarf-rt_v5-rev1/mingw32/bin/../libexec/gcc/i686-w64-mingw32/6.2.0/liblto_plugin-0.dll -plugin-opt=C:/Program Files (x86)/mingw-w64/i686-6.2.0-win32-dwarf-rt_v5-rev1/mingw32/bin/../libexec/gcc/i686-w64-mingw32/6.2.0/lto-wrapper.exe -plugin-opt=-fresolution=C:\Users\AlfP\AppData\Local\Temp\ccXVaxln.res -plugin-opt=-pass-through=-lmingw32 -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lmoldname -plugin-opt=-pass-through=-lmingwex -plugin-opt=-pass-through=-lmsvcrt -plugin-opt=-pass-through=-ladvapi32 -plugin-opt=-pass-through=-lshell32 -plugin-opt=-pass-through=-luser32 -plugin-opt=-pass-through=-lkernel32 -plugin-opt=-pass-through=-liconv -plugin-opt=-pass-through=-lmingw32 -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lmoldname -plugin-opt=-pass-through=-lmingwex -plugin-opt=-pass-through=-lmsvcrt --sysroot=C:/mingw620/i686-620-win32-dwarf-rt_v5-rev1/mingw32 -m i386pe -Bdynamic -u ___register_frame_info -u ___deregister_frame_info --version C:/Program Files (x86)/mingw-w64/i686-6.2.0-win32-dwarf-rt_v5-rev1/mingw32/bin/../lib/gcc/i686-w64-mingw32/6.2.0/../../../../i686-w64-mingw32/lib/../lib/crt2.o C:/Program Files (x86)/mingw-w64/i686-6.2.0-win32-dwarf-rt_v5-rev1/mingw32/bin/../lib/gcc/i686-w64-mingw32/6.2.0/crtbegin.o -LC:/Program Files (x86)/mingw-w64/i686-6.2.0-win32-dwarf-rt_v5-rev1/mingw32/bin/../lib/gcc/i686-w64-mingw32/6.2.0 -LC:/Program Files (x86)/mingw-w64/i686-6.2.0-win32-dwarf-rt_v5-rev1/mingw32/bin/../lib/gcc -LC:/Program Files (x86)/mingw-w64/i686-6.2.0-win32-dwarf-rt_v5-rev1/mingw32/bin/../lib/gcc/i686-w64-mingw32/6.2.0/../../../../i686-w64-mingw32/lib/../lib -LC:/Program Files (x86)/mingw-w64/i686-6.2.0-win32-dwarf-rt_v5-rev1/mingw32/bin/../lib/gcc/i686-w64-mingw32/6.2.0/../../../../lib -LC:/Program Files (x86)/mingw-w64/i686-6.2.0-win32-dwarf-rt_v5-rev1/mingw32/bin/../lib/gcc/i686-w64-mingw32/6.2.0/../../../../i686-w64-mingw32/lib -LC:/Program Files (x86)/mingw-w64/i686-6.2.0-win32-dwarf-rt_v5-rev1/mingw32/bin/../lib/gcc/i686-w64-mingw32/6.2.0/../../.. C:\Users\AlfP\AppData\Local\Temp\ccn2QnTg.o -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcrt -ladvapi32 -lshell32 -luser32 -lkernel32 -liconv -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcrt C:/Program Files (x86)/mingw-w64/i686-6.2.0-win32-dwarf-rt_v5-rev1/mingw32/bin/../lib/gcc/i686-w64-mingw32/6.2.0/crtend.o
GNU ld (GNU Binutils) 2.25
Copyright (C) 2014 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) a later version.
This program has absolutely no warranty.
COLLECT_GCC_OPTIONS='-v' '--version' '-shared-libgcc' '-mtune=generic' '-march=i686'

[C:\my\temp]
> _

共有1个答案

吴伟志
2023-03-14

您可以传递-pedantic-errors,它在G++6.3上给出以下错误消息

main.cpp:1:6: error: ISO C++ forbids declaration of 'main' with no type [-Wpedantic]
 main(){}

现场演示

以下是-pedantic-errors的文档:

 类似资料:
  • 我是Springboot的新手,我通过Sping的教程和“https://spring.io/guides”指南来学习。 现在我试图理解并重做教程:“使用MySQL访问数据” 不幸的是,我在Mavenbuild期间出错: 启动ApplicationContext时出错。要显示自动配置报告,请在启用“调试”的情况下重新运行应用程序。2017-12-07 10:26:42.708错误8100---[m

  • 问题内容: 这是相关的查询。 我有一个包含三列的表:在MS Access中。(实际表很大,但是下面的示例仅供参考)!http://postimg.org/image/bx0grwoa3/ 现在,我想获得以下类型的查询输出:获取每个唯一名称的最小季度值。例如: !http://postimg.org/image/je1w7gdi1/ 到目前为止,通过使用以下命令,我可以通过硬编码标准获得四分之一的输

  • 现在我正在使用Criteria Hibernate查询从员工表中查询所有记录,它工作正常。我需要将员工表与库表联接,其中库。Emp_Id=员工。Emp_id我是否需要从员工表中获取所有记录,并从库表中获取书名和结账日期,作为联接选择查询的一部分。我该怎么做?

  • 问题内容: 您是否需要在标签末尾添加一个?我在W3schools.com上看到了一个不带的示例: 我知道没有必要至少在浏览器中自动关闭标签,但是我应该这样做吗? 问题答案: 该只需要XHTML和XML。 如果您使用的是HTML5文档类型,则 无需以 这种方式 终止自动关闭标签 。 这适用于,,等。 即只要使用,和。 如果您需要一个空元素(如),请不要使用,而应使用。这很重要,因为在HTML5中,斜

  • 当我在JSP中添加标记库时,出现了这个异常。我正在使用spring mvc和spring security。 我的JSP: 添加

  • 问题内容: 如果我想抓取一个需要先使用密码登录的网站,我该如何使用beautifulsoup4库开始使用python抓取它?以下是我对不需要登录的网站的处理方式。 应该如何更改代码以适应登录?假设我要抓取的网站是一个需要登录的论坛。一个示例是http://forum.arduino.cc/index.php 问题答案: 您可以使用机械化: 或urllib-使用urllib2登录网站