I am using Cygwin to compile c++ programs, but I need to know what command do I use to show warnings when there is no endline or new line in the program. I tried using commands like -Wall, -Pedantic, etc but nothing shows up.
Below is the current cygwin I am using.
$ g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-cygwin/7.3.0/lto-wrapper.exe
Target: x86_64-pc-cygwin
Configured with: /cygdrive/i/szsz/tmpp/gcc/gcc-7.3.0-2.x86_64/src/gcc-7.3.0/configure --srcdir=/cygdrive/i/szsz/tmpp/gcc/gcc-7.3.0-2.x86_64/src/gcc-7.3.0 --prefix=/usr --exec-prefix=/usr --localstatedir=/var --sysconfdir=/etc --docdir=/usr/share/doc/gcc --htmldir=/usr/share/doc/gcc/html -C --build=x86_64-pc-cygwin --host=x86_64-pc-cygwin --target=x86_64-pc-cygwin --without-libiconv-prefix --without-libintl-prefix --libexecdir=/usr/lib --enable-shared --enable-shared-libgcc --enable-static --enable-version-specific-runtime-libs --enable-bootstrap --enable-__cxa_atexit --with-dwarf2 --with-tune=generic --enable-languages=ada,c,c++,fortran,lto,objc,obj-c++ --enable-graphite --enable-threads=posix --enable-libatomic --enable-libcilkrts --enable-libgomp --enable-libitm --enable-libquadmath --enable-libquadmath-support --disable-libssp --enable-libada --disable-symvers --with-gnu-ld --with-gnu-as --with-cloog-include=/usr/include/cloog-isl --without-libiconv-prefix --without-libintl-prefix --with-system-zlib --enable-linker-build-id --with-default-libstdcxx-abi=gcc4-compatible --enable-libstdcxx-filesystem-ts
Thread model: posix
gcc version 7.3.0 (GCC)
This is an improvement made by GCC people for portability, gcc 4.3 onwards. There is no way to get this warning back.
See Here: gcc 4.3 no longer warns about missing newlines at end of files
Related
This is what I'm trying to do(on Windows 7 64-bits):
g++ -m64 -o main main.cpp
And the error I get is:
Sorry, unimplemented: 64 bit mode not compiled in ...
I installed mingw-64-install.exe from here: https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/mingw-builds/installer/
But I still get the same error. Do I also need to add the path to this folder in the environment variable?
This is what I get when I type g++ -v:
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=c:/mingw/bin/../libexec/gcc/mingw32/4.9.3/lto-wrapper.exe
Target: mingw32
Configured with: ../src/gcc-4.9.3/configure --build=x86_64-pc-linux-gnu --host=m
ingw32 --prefix=/mingw --disable-win32-registry --target=mingw32 --with-arch=i58
6 --enable-languages=c,c++,objc,obj-c++,fortran,ada --enable-static --enable-sha
red --enable-threads --with-dwarf2 --disable-sjlj-exceptions --enable- version-sp
ecific-runtime-libs --enable-libstdcxx-debug --with-tune=generic --enable-nls
Thread model: win32
gcc version 4.9.3 <GCC>
When running mingw-64-install.exe, you have to choose the x86_64 architecture on the settings screen. With this architecture, 64-bit is also the default target. If you run g++ -v, you should get something like:
C:\>g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=C:/Program\ Files/mingw-w64/x86_64-5.3.0-posix-seh-rt_v4-rev0/mingw64/bin/../libexec/gcc/x86_64-w64-mingw32/5.3.0/lto-wrapper.exe
Target: x86_64-w64-mingw32
Configured with: ../../../src/gcc-5.3.0/configure --host=x86_64-w64-mingw32 --build=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --prefix=/mingw64 --with-sysroot=/c/mingw530/x86_64-530-posix-seh-rt_v4-rev0/mingw64 --with-gxx-include-dir=/mingw64/x86_64-w64-mingw32/include/c++ --enable-shared --enable-static --disable-multilib --enable-languages=c,c++,fortran,lto --enable-libstdcxx-time=yes --enable-threads=posix --enable-libgomp --enable-libatomic --enable-lto --enable-graphite --enable-checking=release --enable-fully-dynamic-string --enable-version-specific-runtime-libs --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=nocona --with-tune=core2 --with-libiconv --with-system-zlib --with-gmp=/c/mingw530/prerequisites/x86_64-w64-mingw32-static --with-mpfr=/c/mingw530/prerequisites/x86_64-w64-mingw32-static --with-mpc=/c/mingw530/prerequisites/x86_64-w64-mingw32-static --with-isl=/c/mingw530/prerequisites/x86_64-w64-mingw32-static --with-pkgversion='x86_64-posix-seh-rev0, Built by MinGW-W64 project' --with-bugurl=http://sourceforge.net/projects/mingw-w64 CFLAGS='-O2 -pipe -I/c/mingw530/x86_64-530-posix-seh-rt_v4-rev0/mingw64/opt/include -I/c/mingw530/prerequisites/x86_64-zlib-static/include -I/c/mingw530/prerequisites/x86_64-w64-mingw32-static/include' CXXFLAGS='-O2 -pipe -I/c/mingw530/x86_64-530-posix-seh-rt_v4-rev0/mingw64/opt/include -I/c/mingw530/prerequisites/x86_64-zlib-static/include -I/c/mingw530/prerequisites/x86_64-w64-mingw32-static/include' CPPFLAGS= LDFLAGS='-pipe -L/c/mingw530/x86_64-530-posix-seh-rt_v4-rev0/mingw64/opt/lib -L/c/mingw530/prerequisites/x86_64-zlib-static/lib -L/c/mingw530/prerequisites/x86_64-w64-mingw32-static/lib '
Thread model: posix
gcc version 5.3.0 (x86_64-posix-seh-rev0, Built by MinGW-W64 project)
The Target line should say x86_64.
Had this problem with Windows 10 Home / AMD Ryzen 5 3400G.
For some reason the mingw64 install program decided for host i686-8.1.0-win32-dwarf-rt_v6-rev0
Solution was copying the mingw64 x86_64-w64-mingw32 installation from another notebook.
when compile the above function, it will print nothing. While if we comment out "char tmp = num[0]", it will print "===test==="
#include <iostream>
using namespace std;
void eval(string num)
{
char tmp = num[0];
}
int main()
{
int i;
cout<<"===test==="<<endl;
return 0;
}
I know it is something wrong in the implementation. I test it in Cygwin, with the following g++ version:
$ g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-cygwin/5.2.0/lto-wrapper.exe
Target: x86_64-pc-cygwin
Configured with: /cygdrive/i/szsz/tmpp/gcc/gcc-5.2.0-1.x86_64/src/gcc-5.2.0/configure --srcdir=/cygdrive/i/szsz/tmpp/gcc/gcc-5.2.0-1.x86_64/src/gcc-5.2.0 --prefix=/usr --exec-prefix=/usr --localstatedir=/var --sysconfdir=/etc --docdir=/usr/share/doc/gcc --htmldir=/usr/share/doc/gcc/html -C --build=x86_64-pc-cygwin --host=x86_64-pc-cygwin --target=x86_64-pc-cygwin --without-libiconv-prefix --without-libintl-prefix --libexecdir=/usr/lib --enable-shared --enable-shared-libgcc --enable-static --enable-version-specific-runtime-libs --enable-bootstrap --enable-__cxa_atexit --with-dwarf2 --with-tune=generic --enable-languages=ada,c,c++,fortran,lto,objc,obj-c++ --enable-graphite --enable-threads=posix --enable-libatomic --enable-libgomp --disable-libitm --enable-libquadmath --enable-libquadmath-support --enable-libssp --enable-libada --enable-libgcj-sublibs --disable-java-awt --disable-symvers --with-ecj-jar=/usr/share/java/ecj.jar --with-gnu-ld --with-gnu-as --with-cloog-include=/usr/include/cloog-isl --without-libiconv-prefix --without-libintl-prefix --with-system-zlib --enable-linker-build-id
Thread model: posix
gcc version 5.2.0 (GCC)
But no such problem in my Ubuntu 14.04.
Could anyone give me an explanation? Really weird. Thanks.
===Updates:
and why I got -2 points for this question?
===Updates2:===
problem solved. We have to install all the related components (gcc-core, g++, libgcc, libsupc, libstdc++ ....) of 5.2.0 version
The problem is something I've seen before. You will find you have a warning about entry point. The linker defaults to the first function as the entry point if it can't determine it. Also, note that moving main() to the first function doesn't fix the problem as the entry point is called with different arguments and a different calling convention.
I'm not sure what you did wrong but it would help if you posted your compilation command.
g++ -o test.exe test.cpp
is the correct command to compile it; note that we must invoke it as ./test due to cygwin (current directory is not in PATH by default).
I installed Mingw 64 on Windows 8 64bit.
There is the return after i type g++ -v
C:\Users\Hobo>g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=C:/Program\ Files\ (x86)/mingw-w64/i686-4.9.2-posix-dwarf-rt_v4-re
v2/mingw32/bin/../libexec/gcc/i686-w64-mingw32/4.9.2/lto-wrapper.exe
Target: i686-w64-mingw32
Configured with: ../../../src/gcc-4.9.2/configure --host=i686-w64-mingw32 --build=i686
-w64-mingw32 --target=i686-w64-mingw32 --prefix=/mingw32 --with-sysroot=/c/mingw492/i6
86-492-posix-dwarf-rt_v4-rev2/mingw32 --with-gxx-include-dir=/mingw32/i686-w64-mingw32
/include/c++ --enable-shared --enable-static --disable-multilib --enable-languages=ada
,c,c++,fortran,objc,obj-c++,lto --enable-libstdcxx-time=yes --enable-threads=posix --e
nable-libgomp --enable-libatomic --enable-lto --enable-graphite --enable-checking=rele
ase --enable-fully-dynamic-string --enable-version-specific-runtime-libs --disable-sjl
j-exceptions --with-dwarf2 --disable-isl-version-check --disable-cloog-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/mingw492/prerequisites/i686-w64-mingw32-static --with-mpfr=/c/mingw492/p
rerequisites/i686-w64-mingw32-static --with-mpc=/c/mingw492/prerequisites/i686-w64-min
gw32-static --with-isl=/c/mingw492/prerequisites/i686-w64-mingw32-static --with-cloog=
/c/mingw492/prerequisites/i686-w64-mingw32-static --enable-cloog-backend=isl --with-pk
gversion='i686-posix-dwarf-rev2, Built by MinGW-W64 project' --with-bugurl=http://sour
ceforge.net/projects/mingw-w64 CFLAGS='-O2 -pipe -I/c/mingw492/i686-492-posix-dwarf-rt
_v4-rev2/mingw32/opt/include -I/c/mingw492/prerequisites/i686-zlib-static/include -I/c
/mingw492/prerequisites/i686-w64-mingw32-static/include' CXXFLAGS='-O2 -pipe -I/c/ming
w492/i686-492-posix-dwarf-rt_v4-rev2/mingw32/opt/include -I/c/mingw492/prerequisites/i
686-zlib-static/include -I/c/mingw492/prerequisites/i686-w64-mingw32-static/include' C
PPFLAGS= LDFLAGS='-pipe -L/c/mingw492/i686-492-posix-dwarf-rt_v4-rev2/mingw32/opt/lib
-L/c/mingw492/prerequisites/i686-zlib-static/lib -L/c/mingw492/prerequisites/i686-w64-
mingw32-static/lib -Wl,--large-address-aware'
Thread model: posix
gcc version 4.9.2 (i686-posix-dwarf-rev2, Built by MinGW-W64 project)
then i use g++ x.cpp -m64
the return is sorry, unimplemented: 64-bit mode not compiled in
what can i do?
so I went to this link Source Forge MinGW to download and install MinGW 4.8.1. (rev 5). I unpack it into C:\MinGW\mingw32. So I open command prompt (win 32 system) and run gcc -v and I get GCC is 4.7.3. This is the full output of gcc -v:
C:\MinGW\mingw32>gcc -v Using built-in specs. COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/i686-pc-cygwin/4.7.3/lto-wrapper.exe
Target: i686-pc-cygwin Configured with:
/cygdrive/i/szsz/git/cygwin-ports-gcc/gcc-4.7.3-1/src/gcc-4.7.3
/configure
--srcdir=/cygdrive/i/szsz/git/cygwin-ports-gcc/gcc-4.7.3-1/src/gcc-4.
7.3 --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --lib execdir=/usr/lib --datadir=/usr/share --localstatedir=/var --sysconfdir=/etc --d atarootdir=/usr/share --docdir=/usr/share/doc/gcc -C --build=i686-pc-cygwin --ho st=i686-pc-cygwin --target=i686-pc-cygwin --without-libiconv-prefix
--without-li bintl-prefix --enable-shared --enable-shared-libgcc --enable-static --enable-ver sion-specific-runtime-libs --enable-bootstrap --disable-__cxa_atexit --with-dwar f2 --with-arch=i686 --with-tune=generic --disable-sjlj-exceptions --enable-langu ages=ada,c,c++,fortran,java,lto,objc,obj-c++ --enable-graphite --enable-threads= posix --enable-libgomp --disable-libitm --enable-libquadmath --enable-libquadmat h-support --enable-libssp --enable-libada --enable-libjava --enable-libgcj-subli bs --disable-java-awt --disable-symvers
--with-ecj-jar=/usr/share/java/ecj.jar -
-with-gnu-ld --with-gnu-as --with-cloog-include=/usr/include/cloog-ppl --with-sy stem-zlib : (reconfigured) /cygdrive/i/szsz/git/cygwin-ports-gcc/gcc-4.7.3-1/src
/gcc-4.7.3/configure
--srcdir=/cygdrive/i/szsz/git/cygwin-ports-gcc/gcc-4.7.3-1/ src/gcc-4.7.3 --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin
--sbindir=/usr/ sbin --libexecdir=/usr/lib --datadir=/usr/share --localstatedir=/var --sysconfdi r=/etc --datarootdir=/usr/share --docdir=/usr/share/doc/gcc -C --build=i686-pc-c ygwin --host=i686-pc-cygwin --target=i686-pc-cygwin --without-libiconv-prefix -- without-libintl-prefix --enable-shared --enable-shared-libgcc --enable-static -- enable-version-specific-runtime-libs --enable-bootstrap
--disable-__cxa_atexit -
-with-dwarf2 --with-arch=i686 --with-tune=generic --disable-sjlj-exceptions --en able-languages=ada,c,c++,fortran,java,lto,objc,obj-c++
--enable-graphite --enabl e-threads=posix --enable-libgomp --disable-libitm --enable-libquadmath --enable- libquadmath-support --enable-libssp --enable-libada --enable-libjava --enable-li bgcj-sublibs --disable-java-awt --disable-symvers
--with-ecj-jar=/usr/share/java /ecj.jar --with-gnu-ld --with-gnu-as --with-cloog-include=/usr/include/cloog-ppl --with-system-zlib Thread model: posix gcc version 4.7.3 (GCC)
C:\MinGW\mingw32>
I would like to know why it unpacked an earlier version and how to fix this. Apparently C::B see's it as an earlier build too! It really baffles me O.o
Also, the prompt returns that threads use Posix when it should be Win32, again really rattling my brain here.
If any one can point to some links, or clear any of this up it would be greatly appreciated!
What you unpacked, and what the OS presents when you call the program, need not be the same thing. Did you do a rehash? Confirm that the path is the same? Or is the new version at a later point in the path? You might want to alias the gcc command to the version you want. Type which gcc to see where the OS thinks the "current version" is located - that should help. EDIT I realize the which command may not work in windows (just noticed the C: drive letter) but the main point about paths is still valid.
I'm debugging somebody else's Qt program and ran into the following error message which I don't understand:
DWARF-2 expression error: DW_OP_reg operations must be used either alone or in
conjuction with DW_OP_piece or DW_OP_bit_piece.
I'm not sure what that means and Google isn't of much help.
Here's the context - sLocation is a QString that was declared a few lines earlier. However, it was created from functions which were inlined, so I'm not sure of its value and am attempting to check before being appended to:
(gdb) printqstring suffix
(QString)0xffffbd80: "sorted"
(gdb) next
1241 sLocation += suffix;
(gdb) printqstring sLocation
Can't take address of "sLocation" which isn't an lvalue.
(gdb) info local
sLocation = <error reading variable sLocation (DWARF-2 expression error:
DW_OP_reg operations must be used either alone or in conjuction with
DW_OP_piece or DW_OP_bit_piece.)>
Could somebody please explain what that error message means or what could cause it?
The error message means that GDB is reading DWARF2 debug info from the executable, and is rejecting that info as invalid (not following the DWARF2 standard).
The invalid info is likely due to a bug in GCC, fixed in SVN revision 147187:
2009-05-06 Jakub Jelinek <jakub#redhat.com>
* dwarf2out.c (new_reg_loc_descr): Don't ever create DW_OP_regX.
(one_reg_loc_descriptor): Create DW_OP_regX here instead of calling
new_reg_loc_descr.
(loc_by_reference): If loc is DW_OP_regX, change it into DW_OP_bregX 0
instead of appending DW_OP_deref*.
I got the same problem running a Ubuntu 10.10 64bit. However, the same code on a 10.04 LTS 32bit works perfectly.
Here is the version output of both setups
Ubuntu 10.10:
$ gcc -v
Using built-in specs.
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.4.4-14ubuntu5' --with-bugurl=file:///usr/share/doc/gcc-4.4/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.4 --enable-shared --enable-multiarch --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.4 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --disable-werror --with-arch-32=i686 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.4.5 (Ubuntu/Linaro 4.4.4-14ubuntu5)
GCC on 10.04 LTS:
$ gcc -v
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.4.3-4ubuntu5' --with-bugurl=file:///usr/share/doc/gcc-4.4/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --enable-shared --enable-multiarch --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.4 --program-suffix=-4.4 --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-plugin --enable-objc-gc --enable-targets=all --disable-werror --with-arch-32=i486 --with-tune=generic --enable-checking=release --build=i486-linux-gnu --host=i486-linux-gnu --target=i486-linux-gnu
Thread model: posix
gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5
Cheers,
Andre