Fri 22 Nov 2002 10:56:04 AM UTC, original submission:
Some gcc-3.x compilers return complex string when used as "g++ --version", unlike gcc-2.95 which returns a simple version number.
This problem appears in all versions of g++ 3.x shipped by Debian. I was unable to test whether the problem also occurs with the official gcc distribution since I was unable to compile any stock gcc 3.x from source.
Example of string returned by gcc on my system:
$ g++-2.95 --version
g++-2.95
$ g++-3.2 --version
g++-3.2 (GCC) 3.2.1 20020924 (Debian prerelease)
Copyright (C) 2002 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.
$ /usr/local/gcc-2.95.3/bin/g++ --version
2.95.3
Proposed work-around: "gcc -v" (sic!) seems to have a more predictible output:
$ /usr/local/gcc-2.95.3/bin/g++ -v
Reading specs from /usr/local/gcc-2.95.3/lib/gcc-lib/i686-pc-linux-gnu/2.95.3/specs
gcc version 2.95.3 20010315 (release)
$ g++-2.95 -v
Reading specs from /usr/lib/gcc-lib/i386-linux/2.95.4/specs
gcc version 2.95.4 20011002 (Debian prerelease)
$ g++-3.2 -v
Reading specs from /usr/lib/gcc-lib/i386-linux/3.2.1/specs
Configured with: /mnt/data/gcc-3.1/gcc-3.2-3.2.1ds2/src/configure -v --enable-languages=c,c++,java,f77,proto,objc,ada --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-gxx-include-dir=/usr/include/c++/3.2 --enable-shared --with-system-zlib --enable-nls --without-included-gettext --enable-java-gc=boehm --enable-objc-gc i386-linux
Thread model: posix
gcc version 3.2.1 20020924 (Debian prerelease)
So "$CXX -v 2>&1 | tail -1 | cut -f3 -d' '" might do the trick...
Maybe there is a cleaner solution.
|