debian/0000755000000000000000000000000012013677520007171 5ustar debian/docs0000644000000000000000000000003512013675421010040 0ustar README gccintro.pdf gccintro debian/compat0000644000000000000000000000000212013675421010365 0ustar 8 debian/changelog0000644000000000000000000000065312013677116011050 0ustar gccintro (1.0-2) unstable; urgency=low * Fix spell errors. * Describe changes made to the upstream more accurately. -- Osamu Aoki Sat, 18 Aug 2012 20:32:58 +0900 gccintro (1.0-1) unstable; urgency=low * Initial release (Closes: #681725) * Patch with upstream 1.1 diff.gz file. * Add security options. * Adjust multiarch. -- Osamu Aoki Mon, 16 Jul 2012 00:58:02 +0900 debian/watch0000644000000000000000000000021312013675421010214 0ustar # See uscan(1) for format version=3 # http://www.network-theory.co.uk/gcc/intro/src/ gccintro-(.*)\.tar\.gz debian/control0000644000000000000000000000230712013675421010574 0ustar Source: gccintro Section: non-free/doc Priority: extra Maintainer: Osamu Aoki Build-Depends: debhelper (>= 8.0.0), texinfo, texlive Standards-Version: 3.9.3 Homepage: http://www.network-theory.co.uk/gcc/intro/ Vcs-Git: git://git.debian.org/collab-maint/gccintro.git Vcs-Browser: http://git.debian.org/?p=collab-maint/gccintro.git;a=summary Package: gccintro Architecture: all Depends: ${misc:Depends} Description: Introduction to GCC by Brian J. Gough This manual provides a tutorial introduction to the GNU C and C++ compilers, gcc and g++. . Many books teach the C and C++ languages, this book explains how to use the compiler itself. Based on years of observation of questions posted on mailing lists, it guides the reader straight to the important options of GCC! . Concisely written, with numerous easy-to-follow "Hello World" examples. . Now with extensive new sections on error messages, portability and floating point arithmetic! . Features a special foreword by Richard M. Stallman, principal developer of GCC and founder of the GNU Project. . The content of this Debian packaged version has some minor adjustments to match learning experiences under the Debian environment. debian/info0000644000000000000000000000005612013675421010046 0ustar gccintro.info gccintro.info-1 gccintro.info-2 debian/copyright0000644000000000000000000000426512013675421011131 0ustar Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Upstream-Name: gccintro Source: http://www.network-theory.co.uk/gcc/intro/src/ Files: * debian/patches/gccintro-1.0-1.1.diff Copyright: 2004, 2005 Network Theory Ltd. License: GFDL-1.2+ Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, with the Front-Cover Texts being ``A Network Theory Manual'', and with the Back-Cover Texts as in (a) below. A copy of the license is included in the section entitled ``GNU Free Documentation License''. . (a) The Back-Cover Text is: ``The development of this manual was funded entirely by Network Theory Ltd. Copies published by Network Theory Ltd raise money for more free documentation.'' . On Debian systems, the full text of the GNU Free Documentation License version 1.2 can be found in the file `/usr/share/common-licenses/GFDL-1.2'. Files: debian/* Copyright: 2012 Osamu Aoki License: Expat Copyright (c) 2012 Osamu Aoki . Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: . The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. . THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. debian/README.Debian0000644000000000000000000000046312013676537011244 0ustar gccintro for Debian ------------------- The content of this Debian packaged version adds a chapter on ``Security enhancement options'' and makes some minor file path adjustments to match learning experiences under the Debian environment. -- Osamu Aoki Sat, 18 Aug 2012 20:32:36 +0900 debian/rules0000755000000000000000000000150512013675421010250 0ustar #!/usr/bin/make -f #export DH_VERBOSE=1 %: dh $@ ### override and do mostly nothing override_dh_auto_clean: override_dh_testdir: override_dh_auto_configure: # keep info page aside [ -e gccintro.info ] && [ ! -e gccintro.info-keep ] && \ mv gccintro.info gccintro.info-keep override_dh_auto_build: makeinfo gccintro.texi makeinfo --html gccintro.texi # next always return with ERROR, ths needs to use - -texi2pdf -b gccintro.texi override_dh_auto_test: override_dh_auto_clean: # restore AUTHORS -touch AUTHORS # restore info page -[ -e gccintro.info-keep ] && \ mv -f gccintro.info-keep gccintro.info # remove generated HTML -rm -rf gccintro/ # remove generated PDF and INFO and secondary files generated by TeX -rm -f $(addprefix gccintro, .pdf .info-1 .info-2 .info-3 .aux .cp .cps .fn .ky .log .toc .tp .vr) debian/source/0000755000000000000000000000000012013675421010467 5ustar debian/source/format0000644000000000000000000000001412013675421011675 0ustar 3.0 (quilt) debian/patches/0000755000000000000000000000000012013675421010616 5ustar debian/patches/series0000644000000000000000000000022712013675421012034 0ustar gccintro-1.0-1.1.diff 0001-Fix-upstream-build-structure-for-Debian.patch 0002-Update-contents-for-Debian.patch 0003-Update-title-etc.-for-Debian.patch debian/patches/0001-Fix-upstream-build-structure-for-Debian.patch0000644000000000000000000000555412013675337021717 0ustar From 221c19e563c77d9835497cf7d7540149f3e529a1 Mon Sep 17 00:00:00 2001 From: Osamu Aoki Date: Fri, 13 Jul 2012 22:24:17 +0900 Subject: [PATCH 1/3] Fix upstream build structure for Debian gccintro.texi No blank page insertion for the PDF-reader and single sided printer No @ifinfo since we need top page for HTML Add GFDL for HTML Add Index for HTML fdl.texi No smallerfonts for HTML/info chg @unnumberedsubsec -> @headinng --- fdl.texi | 4 +++- gccintro.texi | 21 ++++++++++++++------- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/fdl.texi b/fdl.texi index 358f0fd..608b945 100644 --- a/fdl.texi +++ b/fdl.texi @@ -1,5 +1,7 @@ @center Version 1.2, November 2002 +@iftex @smallerfonts @rm +@end iftex @display Copyright @copyright{} 2000,2001,2002 Free Software Foundation, Inc. @@ -403,7 +405,7 @@ number of this License, you may choose any version ever published (not as a draft) by the Free Software Foundation. @end enumerate -@unnumberedsubsec ADDENDUM: How to use this License for your documents +@heading ADDENDUM: How to use this License for your documents To use this License in a document you have written, include a copy of the License in the document and put the following copyright and diff --git a/gccintro.texi b/gccintro.texi index 688c616..bfa0a60 100644 --- a/gccintro.texi +++ b/gccintro.texi @@ -14,7 +14,13 @@ @finalout @end iftex -@setchapternewpage odd +@setchapternewpage on + +@c For installing properly under Debian packaging system +@dircategory Software development +@direntry + * gccintro: (gccintro). Introduction to GCC by Brian J. Gough. +@end direntry @titlepage @title An Introduction to GCC @@ -76,7 +82,7 @@ The Texinfo source for this manual may be obtained from: @* @contents -@ifinfo +@ifnottex @node Top @top An Introduction to GCC @@ -87,7 +93,7 @@ This manual provides an introduction to the GNU C and C++ Compilers, The development of this manual was funded entirely by @uref{http://www.network-theory.co.uk/,Network Theory Ltd}. Copies published by Network Theory Ltd raise money for more free documentation. -@end ifinfo +@end ifnottex @menu * Introduction:: @@ -108,12 +114,15 @@ published by Network Theory Ltd raise money for more free documentation. * Acknowledgements:: * Other books from the publisher:: * Free software organizations:: +@ifnotinfo +* GNU Free Documentation License:: +@end ifnotinfo * Index:: @end menu -@ifnotinfo +@iftex @include rms.texi -@end ifnotinfo +@end iftex @node Introduction @chapter Introduction @@ -6362,11 +6371,9 @@ Project, for writing GCC and making it free software. @include fdl.texi @end ifnotinfo -@ifnothtml @node Index @unnumbered Index @printindex cp -@end ifnothtml @ifset extrablankpages @comment final page must be blank for printed version -- 1.7.10.4 debian/patches/gccintro-1.0-1.1.diff0000644000000000000000000072544012013675421014065 0ustar From: Brian Gough Description: upstream 1.1 release diff.gz Date: August 2005 (1/8/2005) diff -Naur -x '*.info' gccintro-1.0/aclocal.m4 gccintro-1.1/aclocal.m4 --- gccintro-1.0/aclocal.m4 2004-05-06 14:28:35.000000000 +0100 +++ gccintro-1.1/aclocal.m4 2005-08-20 11:53:27.000000000 +0100 @@ -1,7 +1,7 @@ -# generated automatically by aclocal 1.7.5 -*- Autoconf -*- +# generated automatically by aclocal 1.9.6 -*- Autoconf -*- -# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002 -# Free Software Foundation, Inc. +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, +# 2005 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -11,36 +11,91 @@ # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. -# Do all the work for Automake. -*- Autoconf -*- +# Copyright (C) 2002, 2003, 2005 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. -# This macro actually does too much some checks are only needed if -# your package does certain things. But this isn't really a big deal. +# AM_AUTOMAKE_VERSION(VERSION) +# ---------------------------- +# Automake X.Y traces this macro to ensure aclocal.m4 has been +# generated from the m4 files accompanying Automake X.Y. +AC_DEFUN([AM_AUTOMAKE_VERSION], [am__api_version="1.9"]) -# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 -# Free Software Foundation, Inc. +# AM_SET_CURRENT_AUTOMAKE_VERSION +# ------------------------------- +# Call AM_AUTOMAKE_VERSION so it can be traced. +# This function is AC_REQUIREd by AC_INIT_AUTOMAKE. +AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], + [AM_AUTOMAKE_VERSION([1.9.6])]) -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2, or (at your option) -# any later version. +# AM_AUX_DIR_EXPAND -*- Autoconf -*- -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA -# 02111-1307, USA. +# For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets +# $ac_aux_dir to `$srcdir/foo'. In other projects, it is set to +# `$srcdir', `$srcdir/..', or `$srcdir/../..'. +# +# Of course, Automake must honor this variable whenever it calls a +# tool from the auxiliary directory. The problem is that $srcdir (and +# therefore $ac_aux_dir as well) can be either absolute or relative, +# depending on how configure is run. This is pretty annoying, since +# it makes $ac_aux_dir quite unusable in subdirectories: in the top +# source directory, any form will work fine, but in subdirectories a +# relative path needs to be adjusted first. +# +# $ac_aux_dir/missing +# fails when called from a subdirectory if $ac_aux_dir is relative +# $top_srcdir/$ac_aux_dir/missing +# fails if $ac_aux_dir is absolute, +# fails when called from a subdirectory in a VPATH build with +# a relative $ac_aux_dir +# +# The reason of the latter failure is that $top_srcdir and $ac_aux_dir +# are both prefixed by $srcdir. In an in-source build this is usually +# harmless because $srcdir is `.', but things will broke when you +# start a VPATH build or use an absolute $srcdir. +# +# So we could use something similar to $top_srcdir/$ac_aux_dir/missing, +# iff we strip the leading $srcdir from $ac_aux_dir. That would be: +# am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"` +# and then we would define $MISSING as +# MISSING="\${SHELL} $am_aux_dir/missing" +# This will work as long as MISSING is not called from configure, because +# unfortunately $(top_srcdir) has no meaning in configure. +# However there are other variables, like CC, which are often used in +# configure, and could therefore not use this "fixed" $ac_aux_dir. +# +# Another solution, used here, is to always expand $ac_aux_dir to an +# absolute PATH. The drawback is that using absolute paths prevent a +# configured tree to be moved without reconfiguration. -# serial 10 +AC_DEFUN([AM_AUX_DIR_EXPAND], +[dnl Rely on autoconf to set up CDPATH properly. +AC_PREREQ([2.50])dnl +# expand $ac_aux_dir to an absolute path +am_aux_dir=`cd $ac_aux_dir && pwd` +]) -AC_PREREQ([2.54]) +# Do all the work for Automake. -*- Autoconf -*- -# Autoconf 2.50 wants to disallow AM_ names. We explicitly allow -# the ones we care about. -m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 +# Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 12 + +# This macro actually does too much. Some checks are only needed if +# your package does certain things. But this isn't really a big deal. # AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE]) # AM_INIT_AUTOMAKE([OPTIONS]) @@ -54,8 +109,12 @@ # arguments mandatory, and then we can depend on a new Autoconf # release and drop the old call support. AC_DEFUN([AM_INIT_AUTOMAKE], -[AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl - AC_REQUIRE([AC_PROG_INSTALL])dnl +[AC_PREREQ([2.58])dnl +dnl Autoconf wants to disallow AM_ names. We explicitly allow +dnl the ones we care about. +m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl +AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl +AC_REQUIRE([AC_PROG_INSTALL])dnl # test to see if srcdir already configured if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then @@ -94,15 +153,17 @@ AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version}) AM_MISSING_PROG(AUTOHEADER, autoheader) AM_MISSING_PROG(MAKEINFO, makeinfo) -AM_MISSING_PROG(AMTAR, tar) AM_PROG_INSTALL_SH AM_PROG_INSTALL_STRIP +AC_REQUIRE([AM_PROG_MKDIR_P])dnl # We need awk for the "check" target. The system "awk" is bad on # some platforms. AC_REQUIRE([AC_PROG_AWK])dnl AC_REQUIRE([AC_PROG_MAKE_SET])dnl AC_REQUIRE([AM_SET_LEADING_DOT])dnl - +_AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])], + [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])], + [_AM_PROG_TAR([v7])])]) _AM_IF_OPTION([no-dependencies],, [AC_PROVIDE_IFELSE([AC_PROG_CC], [_AM_DEPENDENCIES(CC)], @@ -136,55 +197,148 @@ done echo "timestamp for $1" >`AS_DIRNAME([$1])`/stamp-h[]$_am_stamp_count]) -# Copyright 2002 Free Software Foundation, Inc. +# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2, or (at your option) -# any later version. +# AM_PROG_INSTALL_SH +# ------------------ +# Define $install_sh. +AC_DEFUN([AM_PROG_INSTALL_SH], +[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl +install_sh=${install_sh-"$am_aux_dir/install-sh"} +AC_SUBST(install_sh)]) -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +# Copyright (C) 2003, 2005 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. -# AM_AUTOMAKE_VERSION(VERSION) -# ---------------------------- -# Automake X.Y traces this macro to ensure aclocal.m4 has been -# generated from the m4 files accompanying Automake X.Y. -AC_DEFUN([AM_AUTOMAKE_VERSION],[am__api_version="1.7"]) +# serial 2 -# AM_SET_CURRENT_AUTOMAKE_VERSION -# ------------------------------- -# Call AM_AUTOMAKE_VERSION so it can be traced. -# This function is AC_REQUIREd by AC_INIT_AUTOMAKE. -AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], - [AM_AUTOMAKE_VERSION([1.7.5])]) +# Check whether the underlying file-system supports filenames +# with a leading dot. For instance MS-DOS doesn't. +AC_DEFUN([AM_SET_LEADING_DOT], +[rm -rf .tst 2>/dev/null +mkdir .tst 2>/dev/null +if test -d .tst; then + am__leading_dot=. +else + am__leading_dot=_ +fi +rmdir .tst 2>/dev/null +AC_SUBST([am__leading_dot])]) -# Helper functions for option handling. -*- Autoconf -*- +# Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- -# Copyright 2001, 2002 Free Software Foundation, Inc. +# Copyright (C) 1997, 1999, 2000, 2001, 2003, 2005 +# Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2, or (at your option) -# any later version. +# serial 4 -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA -# 02111-1307, USA. +# AM_MISSING_PROG(NAME, PROGRAM) +# ------------------------------ +AC_DEFUN([AM_MISSING_PROG], +[AC_REQUIRE([AM_MISSING_HAS_RUN]) +$1=${$1-"${am_missing_run}$2"} +AC_SUBST($1)]) -# serial 2 + +# AM_MISSING_HAS_RUN +# ------------------ +# Define MISSING if not defined so far and test if it supports --run. +# If it does, set am_missing_run to use it, otherwise, to nothing. +AC_DEFUN([AM_MISSING_HAS_RUN], +[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl +test x"${MISSING+set}" = xset || MISSING="\${SHELL} $am_aux_dir/missing" +# Use eval to expand $SHELL +if eval "$MISSING --run true"; then + am_missing_run="$MISSING --run " +else + am_missing_run= + AC_MSG_WARN([`missing' script is too old or missing]) +fi +]) + +# Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# AM_PROG_MKDIR_P +# --------------- +# Check whether `mkdir -p' is supported, fallback to mkinstalldirs otherwise. +# +# Automake 1.8 used `mkdir -m 0755 -p --' to ensure that directories +# created by `make install' are always world readable, even if the +# installer happens to have an overly restrictive umask (e.g. 077). +# This was a mistake. There are at least two reasons why we must not +# use `-m 0755': +# - it causes special bits like SGID to be ignored, +# - it may be too restrictive (some setups expect 775 directories). +# +# Do not use -m 0755 and let people choose whatever they expect by +# setting umask. +# +# We cannot accept any implementation of `mkdir' that recognizes `-p'. +# Some implementations (such as Solaris 8's) are not thread-safe: if a +# parallel make tries to run `mkdir -p a/b' and `mkdir -p a/c' +# concurrently, both version can detect that a/ is missing, but only +# one can create it and the other will error out. Consequently we +# restrict ourselves to GNU make (using the --version option ensures +# this.) +AC_DEFUN([AM_PROG_MKDIR_P], +[if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then + # We used to keeping the `.' as first argument, in order to + # allow $(mkdir_p) to be used without argument. As in + # $(mkdir_p) $(somedir) + # where $(somedir) is conditionally defined. However this is wrong + # for two reasons: + # 1. if the package is installed by a user who cannot write `.' + # make install will fail, + # 2. the above comment should most certainly read + # $(mkdir_p) $(DESTDIR)$(somedir) + # so it does not work when $(somedir) is undefined and + # $(DESTDIR) is not. + # To support the latter case, we have to write + # test -z "$(somedir)" || $(mkdir_p) $(DESTDIR)$(somedir), + # so the `.' trick is pointless. + mkdir_p='mkdir -p --' +else + # On NextStep and OpenStep, the `mkdir' command does not + # recognize any option. It will interpret all options as + # directories to create, and then abort because `.' already + # exists. + for d in ./-p ./--version; + do + test -d $d && rmdir $d + done + # $(mkinstalldirs) is defined by Automake if mkinstalldirs exists. + if test -f "$ac_aux_dir/mkinstalldirs"; then + mkdir_p='$(mkinstalldirs)' + else + mkdir_p='$(install_sh) -d' + fi +fi +AC_SUBST([mkdir_p])]) + +# Helper functions for option handling. -*- Autoconf -*- + +# Copyright (C) 2001, 2002, 2003, 2005 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 3 # _AM_MANGLE_OPTION(NAME) # ----------------------- @@ -209,28 +363,16 @@ AC_DEFUN([_AM_IF_OPTION], [m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) -# -# Check to make sure that the build environment is sane. -# - -# Copyright 1996, 1997, 2000, 2001 Free Software Foundation, Inc. - -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2, or (at your option) -# any later version. +# Check to make sure that the build environment is sane. -*- Autoconf -*- -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA -# 02111-1307, USA. +# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005 +# Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. -# serial 3 +# serial 4 # AM_SANITY_CHECK # --------------- @@ -273,162 +415,14 @@ fi AC_MSG_RESULT(yes)]) -# -*- Autoconf -*- - - -# Copyright 1997, 1999, 2000, 2001 Free Software Foundation, Inc. - -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2, or (at your option) -# any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA -# 02111-1307, USA. - -# serial 3 - -# AM_MISSING_PROG(NAME, PROGRAM) -# ------------------------------ -AC_DEFUN([AM_MISSING_PROG], -[AC_REQUIRE([AM_MISSING_HAS_RUN]) -$1=${$1-"${am_missing_run}$2"} -AC_SUBST($1)]) - - -# AM_MISSING_HAS_RUN -# ------------------ -# Define MISSING if not defined so far and test if it supports --run. -# If it does, set am_missing_run to use it, otherwise, to nothing. -AC_DEFUN([AM_MISSING_HAS_RUN], -[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl -test x"${MISSING+set}" = xset || MISSING="\${SHELL} $am_aux_dir/missing" -# Use eval to expand $SHELL -if eval "$MISSING --run true"; then - am_missing_run="$MISSING --run " -else - am_missing_run= - AC_MSG_WARN([`missing' script is too old or missing]) -fi -]) - -# AM_AUX_DIR_EXPAND - -# Copyright 2001 Free Software Foundation, Inc. - -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2, or (at your option) -# any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA -# 02111-1307, USA. - -# For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets -# $ac_aux_dir to `$srcdir/foo'. In other projects, it is set to -# `$srcdir', `$srcdir/..', or `$srcdir/../..'. +# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. # -# Of course, Automake must honor this variable whenever it calls a -# tool from the auxiliary directory. The problem is that $srcdir (and -# therefore $ac_aux_dir as well) can be either absolute or relative, -# depending on how configure is run. This is pretty annoying, since -# it makes $ac_aux_dir quite unusable in subdirectories: in the top -# source directory, any form will work fine, but in subdirectories a -# relative path needs to be adjusted first. -# -# $ac_aux_dir/missing -# fails when called from a subdirectory if $ac_aux_dir is relative -# $top_srcdir/$ac_aux_dir/missing -# fails if $ac_aux_dir is absolute, -# fails when called from a subdirectory in a VPATH build with -# a relative $ac_aux_dir -# -# The reason of the latter failure is that $top_srcdir and $ac_aux_dir -# are both prefixed by $srcdir. In an in-source build this is usually -# harmless because $srcdir is `.', but things will broke when you -# start a VPATH build or use an absolute $srcdir. -# -# So we could use something similar to $top_srcdir/$ac_aux_dir/missing, -# iff we strip the leading $srcdir from $ac_aux_dir. That would be: -# am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"` -# and then we would define $MISSING as -# MISSING="\${SHELL} $am_aux_dir/missing" -# This will work as long as MISSING is not called from configure, because -# unfortunately $(top_srcdir) has no meaning in configure. -# However there are other variables, like CC, which are often used in -# configure, and could therefore not use this "fixed" $ac_aux_dir. -# -# Another solution, used here, is to always expand $ac_aux_dir to an -# absolute PATH. The drawback is that using absolute paths prevent a -# configured tree to be moved without reconfiguration. - -# Rely on autoconf to set up CDPATH properly. -AC_PREREQ([2.50]) - -AC_DEFUN([AM_AUX_DIR_EXPAND], [ -# expand $ac_aux_dir to an absolute path -am_aux_dir=`cd $ac_aux_dir && pwd` -]) - -# AM_PROG_INSTALL_SH -# ------------------ -# Define $install_sh. - -# Copyright 2001 Free Software Foundation, Inc. - -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2, or (at your option) -# any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA -# 02111-1307, USA. - -AC_DEFUN([AM_PROG_INSTALL_SH], -[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl -install_sh=${install_sh-"$am_aux_dir/install-sh"} -AC_SUBST(install_sh)]) +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. # AM_PROG_INSTALL_STRIP - -# Copyright 2001 Free Software Foundation, Inc. - -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2, or (at your option) -# any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA -# 02111-1307, USA. - +# --------------------- # One issue with vendor `install' (even GNU) is that you can't # specify the program used to strip binaries. This is especially # annoying in cross-compiling environments, where the build's strip @@ -449,372 +443,99 @@ INSTALL_STRIP_PROGRAM="\${SHELL} \$(install_sh) -c -s" AC_SUBST([INSTALL_STRIP_PROGRAM])]) -# -*- Autoconf -*- -# Copyright (C) 2003 Free Software Foundation, Inc. - -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2, or (at your option) -# any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA -# 02111-1307, USA. - -# serial 1 +# Check how to create a tarball. -*- Autoconf -*- -# Check whether the underlying file-system supports filenames -# with a leading dot. For instance MS-DOS doesn't. -AC_DEFUN([AM_SET_LEADING_DOT], -[rm -rf .tst 2>/dev/null -mkdir .tst 2>/dev/null -if test -d .tst; then - am__leading_dot=. -else - am__leading_dot=_ -fi -rmdir .tst 2>/dev/null -AC_SUBST([am__leading_dot])]) - -# serial 5 -*- Autoconf -*- - -# Copyright (C) 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. - -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2, or (at your option) -# any later version. +# Copyright (C) 2004, 2005 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA -# 02111-1307, USA. - - -# There are a few dirty hacks below to avoid letting `AC_PROG_CC' be -# written in clear, in which case automake, when reading aclocal.m4, -# will think it sees a *use*, and therefore will trigger all it's -# C support machinery. Also note that it means that autoscan, seeing -# CC etc. in the Makefile, will ask for an AC_PROG_CC use... +# serial 2 +# _AM_PROG_TAR(FORMAT) +# -------------------- +# Check how to create a tarball in format FORMAT. +# FORMAT should be one of `v7', `ustar', or `pax'. +# +# Substitute a variable $(am__tar) that is a command +# writing to stdout a FORMAT-tarball containing the directory +# $tardir. +# tardir=directory && $(am__tar) > result.tar +# +# Substitute a variable $(am__untar) that extract such +# a tarball read from stdin. +# $(am__untar) < result.tar +AC_DEFUN([_AM_PROG_TAR], +[# Always define AMTAR for backward compatibility. +AM_MISSING_PROG([AMTAR], [tar]) +m4_if([$1], [v7], + [am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'], + [m4_case([$1], [ustar],, [pax],, + [m4_fatal([Unknown tar format])]) +AC_MSG_CHECKING([how to create a $1 tar archive]) +# Loop over all known methods to create a tar archive until one works. +_am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none' +_am_tools=${am_cv_prog_tar_$1-$_am_tools} +# Do not fold the above two line into one, because Tru64 sh and +# Solaris sh will not grok spaces in the rhs of `-'. +for _am_tool in $_am_tools +do + case $_am_tool in + gnutar) + for _am_tar in tar gnutar gtar; + do + AM_RUN_LOG([$_am_tar --version]) && break + done + am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"' + am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"' + am__untar="$_am_tar -xf -" + ;; + plaintar) + # Must skip GNU tar: if it does not support --format= it doesn't create + # ustar tarball either. + (tar --version) >/dev/null 2>&1 && continue + am__tar='tar chf - "$$tardir"' + am__tar_='tar chf - "$tardir"' + am__untar='tar xf -' + ;; + pax) + am__tar='pax -L -x $1 -w "$$tardir"' + am__tar_='pax -L -x $1 -w "$tardir"' + am__untar='pax -r' + ;; + cpio) + am__tar='find "$$tardir" -print | cpio -o -H $1 -L' + am__tar_='find "$tardir" -print | cpio -o -H $1 -L' + am__untar='cpio -i -H $1 -d' + ;; + none) + am__tar=false + am__tar_=false + am__untar=false + ;; + esac + # If the value was cached, stop now. We just wanted to have am__tar + # and am__untar set. + test -n "${am_cv_prog_tar_$1}" && break -# _AM_DEPENDENCIES(NAME) -# ---------------------- -# See how the compiler implements dependency checking. -# NAME is "CC", "CXX", "GCJ", or "OBJC". -# We try a few techniques and use that to set a single cache variable. -# -# We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was -# modified to invoke _AM_DEPENDENCIES(CC); we would have a circular -# dependency, and given that the user is not expected to run this macro, -# just rely on AC_PROG_CC. -AC_DEFUN([_AM_DEPENDENCIES], -[AC_REQUIRE([AM_SET_DEPDIR])dnl -AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl -AC_REQUIRE([AM_MAKE_INCLUDE])dnl -AC_REQUIRE([AM_DEP_TRACK])dnl - -ifelse([$1], CC, [depcc="$CC" am_compiler_list=], - [$1], CXX, [depcc="$CXX" am_compiler_list=], - [$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'], - [$1], GCJ, [depcc="$GCJ" am_compiler_list='gcc3 gcc'], - [depcc="$$1" am_compiler_list=]) - -AC_CACHE_CHECK([dependency style of $depcc], - [am_cv_$1_dependencies_compiler_type], -[if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then - # We make a subdir and do the tests there. Otherwise we can end up - # making bogus files that we don't know about and never remove. For - # instance it was reported that on HP-UX the gcc test will end up - # making a dummy file named `D' -- because `-MD' means `put the output - # in D'. + # tar/untar a dummy directory, and stop if the command works + rm -rf conftest.dir mkdir conftest.dir - # Copy depcomp to subdir because otherwise we won't find it if we're - # using a relative directory. - cp "$am_depcomp" conftest.dir - cd conftest.dir - - am_cv_$1_dependencies_compiler_type=none - if test "$am_compiler_list" = ""; then - am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp` - fi - for depmode in $am_compiler_list; do - # We need to recreate these files for each test, as the compiler may - # overwrite some of them when testing with obscure command lines. - # This happens at least with the AIX C compiler. - echo '#include "conftest.h"' > conftest.c - echo 'int i;' > conftest.h - echo "${am__include} ${am__quote}conftest.Po${am__quote}" > confmf - - case $depmode in - nosideeffect) - # after this tag, mechanisms are not by side-effect, so they'll - # only be used when explicitly requested - if test "x$enable_dependency_tracking" = xyes; then - continue - else - break - fi - ;; - none) break ;; - esac - # We check with `-c' and `-o' for the sake of the "dashmstdout" - # mode. It turns out that the SunPro C++ compiler does not properly - # handle `-M -o', and we need to detect this. - if depmode=$depmode \ - source=conftest.c object=conftest.o \ - depfile=conftest.Po tmpdepfile=conftest.TPo \ - $SHELL ./depcomp $depcc -c -o conftest.o conftest.c \ - >/dev/null 2>conftest.err && - grep conftest.h conftest.Po > /dev/null 2>&1 && - ${MAKE-make} -s -f confmf > /dev/null 2>&1; then - # icc doesn't choke on unknown options, it will just issue warnings - # (even with -Werror). So we grep stderr for any message - # that says an option was ignored. - if grep 'ignoring option' conftest.err >/dev/null 2>&1; then :; else - am_cv_$1_dependencies_compiler_type=$depmode - break - fi - fi - done - - cd .. + echo GrepMe > conftest.dir/file + AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar]) rm -rf conftest.dir -else - am_cv_$1_dependencies_compiler_type=none -fi -]) -AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type]) -AM_CONDITIONAL([am__fastdep$1], [ - test "x$enable_dependency_tracking" != xno \ - && test "$am_cv_$1_dependencies_compiler_type" = gcc3]) -]) - - -# AM_SET_DEPDIR -# ------------- -# Choose a directory name for dependency files. -# This macro is AC_REQUIREd in _AM_DEPENDENCIES -AC_DEFUN([AM_SET_DEPDIR], -[AC_REQUIRE([AM_SET_LEADING_DOT])dnl -AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl -]) - - -# AM_DEP_TRACK -# ------------ -AC_DEFUN([AM_DEP_TRACK], -[AC_ARG_ENABLE(dependency-tracking, -[ --disable-dependency-tracking Speeds up one-time builds - --enable-dependency-tracking Do not reject slow dependency extractors]) -if test "x$enable_dependency_tracking" != xno; then - am_depcomp="$ac_aux_dir/depcomp" - AMDEPBACKSLASH='\' -fi -AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno]) -AC_SUBST([AMDEPBACKSLASH]) -]) - -# Generate code to set up dependency tracking. -*- Autoconf -*- - -# Copyright 1999, 2000, 2001, 2002 Free Software Foundation, Inc. - -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2, or (at your option) -# any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA -# 02111-1307, USA. - -#serial 2 - -# _AM_OUTPUT_DEPENDENCY_COMMANDS -# ------------------------------ -AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], -[for mf in $CONFIG_FILES; do - # Strip MF so we end up with the name of the file. - mf=`echo "$mf" | sed -e 's/:.*$//'` - # Check whether this is an Automake generated Makefile or not. - # We used to match only the files named `Makefile.in', but - # some people rename them; so instead we look at the file content. - # Grep'ing the first line is not enough: some people post-process - # each Makefile.in and add a new line on top of each file to say so. - # So let's grep whole file. - if grep '^#.*generated by automake' $mf > /dev/null 2>&1; then - dirpart=`AS_DIRNAME("$mf")` - else - continue + if test -s conftest.tar; then + AM_RUN_LOG([$am__untar /dev/null 2>&1 && break fi - grep '^DEP_FILES *= *[[^ @%:@]]' < "$mf" > /dev/null || continue - # Extract the definition of DEP_FILES from the Makefile without - # running `make'. - DEPDIR=`sed -n -e '/^DEPDIR = / s///p' < "$mf"` - test -z "$DEPDIR" && continue - # When using ansi2knr, U may be empty or an underscore; expand it - U=`sed -n -e '/^U = / s///p' < "$mf"` - test -d "$dirpart/$DEPDIR" || mkdir "$dirpart/$DEPDIR" - # We invoke sed twice because it is the simplest approach to - # changing $(DEPDIR) to its actual value in the expansion. - for file in `sed -n -e ' - /^DEP_FILES = .*\\\\$/ { - s/^DEP_FILES = // - :loop - s/\\\\$// - p - n - /\\\\$/ b loop - p - } - /^DEP_FILES = / s/^DEP_FILES = //p' < "$mf" | \ - sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do - # Make sure the directory exists. - test -f "$dirpart/$file" && continue - fdir=`AS_DIRNAME(["$file"])` - AS_MKDIR_P([$dirpart/$fdir]) - # echo "creating $dirpart/$file" - echo '# dummy' > "$dirpart/$file" - done done -])# _AM_OUTPUT_DEPENDENCY_COMMANDS +rm -rf conftest.dir - -# AM_OUTPUT_DEPENDENCY_COMMANDS -# ----------------------------- -# This macro should only be invoked once -- use via AC_REQUIRE. -# -# This code is only required when automatic dependency tracking -# is enabled. FIXME. This creates each `.P' file that we will -# need in order to bootstrap the dependency handling code. -AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS], -[AC_CONFIG_COMMANDS([depfiles], - [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS], - [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"]) -]) - -# Check to see how 'make' treats includes. -*- Autoconf -*- - -# Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc. - -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2, or (at your option) -# any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA -# 02111-1307, USA. - -# serial 2 - -# AM_MAKE_INCLUDE() -# ----------------- -# Check to see how make treats includes. -AC_DEFUN([AM_MAKE_INCLUDE], -[am_make=${MAKE-make} -cat > confinc << 'END' -am__doit: - @echo done -.PHONY: am__doit -END -# If we don't find an include directive, just comment out the code. -AC_MSG_CHECKING([for style of include used by $am_make]) -am__include="#" -am__quote= -_am_result=none -# First try GNU make style include. -echo "include confinc" > confmf -# We grep out `Entering directory' and `Leaving directory' -# messages which can occur if `w' ends up in MAKEFLAGS. -# In particular we don't look at `^make:' because GNU make might -# be invoked under some other name (usually "gmake"), in which -# case it prints its new name instead of `make'. -if test "`$am_make -s -f confmf 2> /dev/null | grep -v 'ing directory'`" = "done"; then - am__include=include - am__quote= - _am_result=GNU -fi -# Now try BSD make style include. -if test "$am__include" = "#"; then - echo '.include "confinc"' > confmf - if test "`$am_make -s -f confmf 2> /dev/null`" = "done"; then - am__include=.include - am__quote="\"" - _am_result=BSD - fi -fi -AC_SUBST([am__include]) -AC_SUBST([am__quote]) -AC_MSG_RESULT([$_am_result]) -rm -f confinc confmf -]) - -# AM_CONDITIONAL -*- Autoconf -*- - -# Copyright 1997, 2000, 2001 Free Software Foundation, Inc. - -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2, or (at your option) -# any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA -# 02111-1307, USA. - -# serial 5 - -AC_PREREQ(2.52) - -# AM_CONDITIONAL(NAME, SHELL-CONDITION) -# ------------------------------------- -# Define a conditional. -AC_DEFUN([AM_CONDITIONAL], -[ifelse([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])], - [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl -AC_SUBST([$1_TRUE]) -AC_SUBST([$1_FALSE]) -if $2; then - $1_TRUE= - $1_FALSE='#' -else - $1_TRUE='#' - $1_FALSE= -fi -AC_CONFIG_COMMANDS_PRE( -[if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then - AC_MSG_ERROR([conditional "$1" was never defined. -Usually this means the macro was only invoked conditionally.]) -fi])]) +AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool]) +AC_MSG_RESULT([$am_cv_prog_tar_$1])]) +AC_SUBST([am__tar]) +AC_SUBST([am__untar]) +]) # _AM_PROG_TAR diff -Naur -x '*.info' gccintro-1.0/associations.texi gccintro-1.1/associations.texi --- gccintro-1.0/associations.texi 2004-04-07 18:53:56.000000000 +0100 +++ gccintro-1.1/associations.texi 2005-07-20 17:40:03.000000000 +0100 @@ -1,78 +1,33 @@ -@cindex Free software organizations The GNU Compiler Collection is part of the GNU Project, launched in 1984 to develop a complete Unix-like operating system which is free software: the GNU system. The Free Software Foundation (FSF) is a tax-exempt charity that raises funds for continuing work on the GNU Project. It is dedicated to -promoting your right to use, study, copy, modify, and redistribute +promoting the right to use, study, copy, modify, and redistribute computer programs. One of the best ways to help the development of free software is to become an associate member of the Free Software -Foundation, and pay regular dues to support their efforts---for more -information visit the FSF website: +Foundation, and pay regular dues to support their efforts. -@table @cite -@item Free Software Foundation (FSF) -United States ---- @uref{http://www.fsf.org/} -@end table -@noindent -Around the world there are many other local free software membership -organizations which support the aims of the Free Software Foundation, -including: +Associate members of the Free Software Foundation receive many benefits, +including regular newsletters, admission to the FSF annual meeting, and +discounts on books and CDROMs published by GNU Press. Membership dues +are also tax deductible in the USA. For more information on becoming a +member, visit the FSF website at @uref{http://www.fsf.org/}. + +The Free Software Foundation Europe (FSFE) is a sister organisation of +the Free Software Foundation. The FSFE is active in promoting free +software at all levels in Europe. For an annual membership fee, +individuals can join FSFE and support its work. Members receive a +personalised GPG-compatible membership smartcard, allowing secure +digital authentication of email and files, and gain access to the ``FSFE +Fellowship'', an electronic community for software freedom. For more +information, visit the FSFE website at @uref{http://www.fsfe.org/}. -@table @cite -@item Free Software Foundation Europe (FSF Europe) -Europe ---- @uref{http://www.fsfeurope.org/} - -@item Association for Free Software (AFFS) -United Kingdom ---- @uref{http://www.affs.org.uk/} - -@item Irish Free Software Organisation (IFSO) -Ireland ---- @uref{http://www.ifso.info/} - -@item Association for Promotion and Research in Libre Computing (APRIL) -France ---- @uref{http://www.april.org/} - -@item Associazione Software Libero -Italy ---- @uref{http://www.softwarelibero.it/} - -@item Verein zur F@"orderung Freier Software (FFIS) -Germany ---- @uref{http://www.ffis.de/} - -@item Verein zur F@"orderung Freier Software -Austria ---- @uref{http://www.ffs.or.at/} - -@item Association Electronique Libre (AEL) -Belgium ---- @uref{http://www.ael.be/} - -@item National Association for Free Software (ANSOL) -Portugal ---- @uref{http://www.ansol.org/} - -@item Free Software Initiative of Japan (FSIJ) -Japan ---- @uref{http://www.fsij.org/} - -@item Free Software Foundation of India (FSF India) -India ---- @uref{http://www.fsf.org.in/} -@end table - -The @cite{Foundation for a Free Information Infrastructure (FFII)} is an -important organization in Europe. FFII is not specific to free +The @cite{Foundation for a Free Information Infrastructure (FFII)} is +another important organization in Europe. FFII is not specific to free software, but works to defend the rights of all programmers and computer users against monopolies in the field of computing, such as patents on -software. - -For more information about FFII, or to support their work with a -donation, visit their website at @uref{http://www.ffii.org/}. +software. For more information about FFII, or to support their work +with a donation, visit their website at @uref{http://www.ffii.org/}. diff -Naur -x '*.info' gccintro-1.0/AUTHORS gccintro-1.1/AUTHORS --- gccintro-1.0/AUTHORS 2004-02-16 16:36:35.000000000 +0000 +++ gccintro-1.1/AUTHORS 2005-08-20 11:51:13.000000000 +0100 @@ -0,0 +1 @@ +Brian Gough (bjg@gnu.org) diff -Naur -x '*.info' gccintro-1.0/c1makefile2 gccintro-1.1/c1makefile2 --- gccintro-1.0/c1makefile2 1970-01-01 01:00:00.000000000 +0100 +++ gccintro-1.1/c1makefile2 2005-07-20 17:46:03.000000000 +0100 @@ -0,0 +1,6 @@ +CC=gcc +CFLAGS=-Wall +main: main.o hello_fn.o + +clean: + rm -f main main.o hello_fn.o diff -Naur -x '*.info' gccintro-1.0/calc2.c gccintro-1.1/calc2.c --- gccintro-1.0/calc2.c 2004-01-23 14:28:35.000000000 +0000 +++ gccintro-1.1/calc2.c 1970-01-01 01:00:00.000000000 +0100 @@ -1,9 +0,0 @@ -#include - -int -main (void) -{ - double x = exp (1.0); - printf ("The value of e(1) is %f\n", x); - return 0; -} diff -Naur -x '*.info' gccintro-1.0/check.c gccintro-1.1/check.c --- gccintro-1.0/check.c 2003-09-29 13:41:52.000000000 +0100 +++ gccintro-1.1/check.c 1970-01-01 01:00:00.000000000 +0100 @@ -1,7 +0,0 @@ -int -main (void) -{ - double x[10], y; - y = x[3]; - return 0; -} diff -Naur -x '*.info' gccintro-1.0/configure gccintro-1.1/configure --- gccintro-1.0/configure 2004-05-06 14:28:48.000000000 +0100 +++ gccintro-1.1/configure 2005-08-20 11:54:28.000000000 +0100 @@ -1,9 +1,8 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.57 for gccintro 1.0. +# Generated by GNU Autoconf 2.59 for gccintro 1.1. # -# Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002 -# Free Software Foundation, Inc. +# Copyright (C) 2003 Free Software Foundation, Inc. # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. ## --------------------- ## @@ -20,9 +19,10 @@ elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then set -o posix fi +DUALCASE=1; export DUALCASE # for MKS sh # Support unset when possible. -if (FOO=FOO; unset FOO) >/dev/null 2>&1; then +if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then as_unset=unset else as_unset=false @@ -41,7 +41,7 @@ LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ LC_TELEPHONE LC_TIME do - if (set +x; test -n "`(eval $as_var=C; export $as_var) 2>&1`"); then + if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then eval $as_var=C; export $as_var else $as_unset $as_var @@ -218,16 +218,17 @@ if mkdir -p . 2>/dev/null; then as_mkdir_p=: else + test -d ./-p && rmdir ./-p as_mkdir_p=false fi as_executable_p="test -f" # Sed expression to map a string onto a valid CPP name. -as_tr_cpp="sed y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g" +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. -as_tr_sh="sed y%*+%pp%;s%[^_$as_cr_alnum]%_%g" +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" # IFS @@ -266,12 +267,12 @@ # Identity of this package. PACKAGE_NAME='gccintro' PACKAGE_TARNAME='gccintro' -PACKAGE_VERSION='1.0' -PACKAGE_STRING='gccintro 1.0' +PACKAGE_VERSION='1.1' +PACKAGE_STRING='gccintro 1.1' PACKAGE_BUGREPORT='' ac_unique_file="gccintro.texi" -ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO AMTAR install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM AWK SET_MAKE am__leading_dot LIBOBJS LTLIBOBJS' +ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar LIBOBJS LTLIBOBJS' ac_subst_files='' # Initialize some variables set by options. @@ -630,7 +631,7 @@ # Be sure to have absolute paths. for ac_var in bindir sbindir libexecdir datadir sysconfdir sharedstatedir \ - localstatedir libdir includedir oldincludedir infodir mandir + localstatedir libdir includedir oldincludedir infodir mandir do eval ac_val=$`echo $ac_var` case $ac_val in @@ -670,10 +671,10 @@ # Try the directory containing this script, then its parent. ac_confdir=`(dirname "$0") 2>/dev/null || $as_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$0" : 'X\(//\)[^/]' \| \ - X"$0" : 'X\(//\)$' \| \ - X"$0" : 'X\(/\)' \| \ - . : '\(.\)' 2>/dev/null || + X"$0" : 'X\(//\)[^/]' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || echo X"$0" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } /^X\(\/\/\)[^/].*/{ s//\1/; q; } @@ -720,7 +721,7 @@ # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures gccintro 1.0 to adapt to many kinds of systems. +\`configure' configures gccintro 1.1 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -745,9 +746,9 @@ cat <<_ACEOF Installation directories: --prefix=PREFIX install architecture-independent files in PREFIX - [$ac_default_prefix] + [$ac_default_prefix] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX - [PREFIX] + [PREFIX] By default, \`make install' will install all the files in \`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify @@ -782,7 +783,7 @@ if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of gccintro 1.0:";; + short | recursive ) echo "Configuration of gccintro 1.1:";; esac cat <<\_ACEOF @@ -819,12 +820,45 @@ ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_builddir$srcdir ;; esac -# Don't blindly perform a `cd "$ac_dir"/$ac_foo && pwd` since $ac_foo can be -# absolute. -ac_abs_builddir=`cd "$ac_dir" && cd $ac_builddir && pwd` -ac_abs_top_builddir=`cd "$ac_dir" && cd ${ac_top_builddir}. && pwd` -ac_abs_srcdir=`cd "$ac_dir" && cd $ac_srcdir && pwd` -ac_abs_top_srcdir=`cd "$ac_dir" && cd $ac_top_srcdir && pwd` + +# Do not use `cd foo && pwd` to compute absolute paths, because +# the directories may not exist. +case `pwd` in +.) ac_abs_builddir="$ac_dir";; +*) + case "$ac_dir" in + .) ac_abs_builddir=`pwd`;; + [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";; + *) ac_abs_builddir=`pwd`/"$ac_dir";; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_top_builddir=${ac_top_builddir}.;; +*) + case ${ac_top_builddir}. in + .) ac_abs_top_builddir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;; + *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_srcdir=$ac_srcdir;; +*) + case $ac_srcdir in + .) ac_abs_srcdir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;; + *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_top_srcdir=$ac_top_srcdir;; +*) + case $ac_top_srcdir in + .) ac_abs_top_srcdir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;; + *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;; + esac;; +esac cd $ac_dir # Check for guested configure; otherwise get Cygnus style configure. @@ -835,7 +869,7 @@ echo $SHELL $ac_srcdir/configure --help=recursive elif test -f $ac_srcdir/configure.ac || - test -f $ac_srcdir/configure.in; then + test -f $ac_srcdir/configure.in; then echo $ac_configure --help else @@ -848,11 +882,10 @@ test -n "$ac_init_help" && exit 0 if $ac_init_version; then cat <<\_ACEOF -gccintro configure 1.0 -generated by GNU Autoconf 2.57 +gccintro configure 1.1 +generated by GNU Autoconf 2.59 -Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002 -Free Software Foundation, Inc. +Copyright (C) 2003 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF @@ -863,8 +896,8 @@ This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by gccintro $as_me 1.0, which was -generated by GNU Autoconf 2.57. Invocation command line was +It was created by gccintro $as_me 1.1, which was +generated by GNU Autoconf 2.59. Invocation command line was $ $0 $@ @@ -941,19 +974,19 @@ 2) ac_configure_args1="$ac_configure_args1 '$ac_arg'" if test $ac_must_keep_next = true; then - ac_must_keep_next=false # Got value, back to normal. + ac_must_keep_next=false # Got value, back to normal. else - case $ac_arg in - *=* | --config-cache | -C | -disable-* | --disable-* \ - | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ - | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ - | -with-* | --with-* | -without-* | --without-* | --x) - case "$ac_configure_args0 " in - "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; - esac - ;; - -* ) ac_must_keep_next=true ;; - esac + case $ac_arg in + *=* | --config-cache | -C | -disable-* | --disable-* \ + | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ + | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ + | -with-* | --with-* | -without-* | --without-* | --x) + case "$ac_configure_args0 " in + "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; + esac + ;; + -* ) ac_must_keep_next=true ;; + esac fi ac_configure_args="$ac_configure_args$ac_sep'$ac_arg'" # Get rid of the leading space. @@ -987,12 +1020,12 @@ case `(ac_space='"'"' '"'"'; set | grep ac_space) 2>&1` in *ac_space=\ *) sed -n \ - "s/'"'"'/'"'"'\\\\'"'"''"'"'/g; - s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='"'"'\\2'"'"'/p" + "s/'"'"'/'"'"'\\\\'"'"''"'"'/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='"'"'\\2'"'"'/p" ;; *) sed -n \ - "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" + "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" ;; esac; } @@ -1021,7 +1054,7 @@ for ac_var in $ac_subst_files do eval ac_val=$`echo $ac_var` - echo "$ac_var='"'"'$ac_val'"'"'" + echo "$ac_var='"'"'$ac_val'"'"'" done | sort echo fi @@ -1040,7 +1073,7 @@ echo "$as_me: caught signal $ac_signal" echo "$as_me: exit $exit_status" } >&5 - rm -f core core.* *.core && + rm -f core *.core && rm -rf conftest* confdefs* conf$$* $ac_clean_files && exit $exit_status ' 0 @@ -1120,7 +1153,7 @@ # value. ac_cache_corrupted=false for ac_var in `(set) 2>&1 | - sed -n 's/^ac_env_\([a-zA-Z_0-9]*\)_set=.*/\1/p'`; do + sed -n 's/^ac_env_\([a-zA-Z_0-9]*\)_set=.*/\1/p'`; do eval ac_old_set=\$ac_cv_env_${ac_var}_set eval ac_new_set=\$ac_env_${ac_var}_set eval ac_old_val="\$ac_cv_env_${ac_var}_value" @@ -1137,13 +1170,13 @@ ,);; *) if test "x$ac_old_val" != "x$ac_new_val"; then - { echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5 + { echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5 echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} - { echo "$as_me:$LINENO: former value: $ac_old_val" >&5 + { echo "$as_me:$LINENO: former value: $ac_old_val" >&5 echo "$as_me: former value: $ac_old_val" >&2;} - { echo "$as_me:$LINENO: current value: $ac_new_val" >&5 + { echo "$as_me:$LINENO: current value: $ac_new_val" >&5 echo "$as_me: current value: $ac_new_val" >&2;} - ac_cache_corrupted=: + ac_cache_corrupted=: fi;; esac # Pass precious variables to config.status. @@ -1200,7 +1233,7 @@ -am__api_version="1.7" +am__api_version="1.9" ac_aux_dir= for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do if test -f $ac_dir/install-sh; then @@ -1237,6 +1270,7 @@ # AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag # AFS /usr/afsws/bin/install, which mishandles nonexistent args # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" +# OS/2's system install, which has a completely different semantic # ./install, which can be erroneously created by make from ./install.sh. echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5 echo $ECHO_N "checking for a BSD-compatible install... $ECHO_C" >&6 @@ -1253,6 +1287,7 @@ case $as_dir/ in ./ | .// | /cC/* | \ /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ + ?:\\/os2\\/install\\/* | ?:\\/OS2\\/INSTALL\\/* | \ /usr/ucb/* ) ;; *) # OSF1 and SCO ODT 3.0 have their own names for install. @@ -1260,20 +1295,20 @@ # by default. for ac_prog in ginstall scoinst install; do for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then - if test $ac_prog = install && - grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then - # AIX install. It has an incompatible calling convention. - : - elif test $ac_prog = install && - grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then - # program-specific install script used by HP pwplus--don't use. - : - else - ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" - break 3 - fi - fi + if $as_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then + if test $ac_prog = install && + grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # AIX install. It has an incompatible calling convention. + : + elif test $ac_prog = install && + grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # program-specific install script used by HP pwplus--don't use. + : + else + ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" + break 3 + fi + fi done done ;; @@ -1361,7 +1396,6 @@ program_transform_name=`echo $program_transform_name | sed -f conftest.sed` rm conftest.sed - # expand $ac_aux_dir to an absolute path am_aux_dir=`cd $ac_aux_dir && pwd` @@ -1375,6 +1409,39 @@ echo "$as_me: WARNING: \`missing' script is too old or missing" >&2;} fi +if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then + # We used to keeping the `.' as first argument, in order to + # allow $(mkdir_p) to be used without argument. As in + # $(mkdir_p) $(somedir) + # where $(somedir) is conditionally defined. However this is wrong + # for two reasons: + # 1. if the package is installed by a user who cannot write `.' + # make install will fail, + # 2. the above comment should most certainly read + # $(mkdir_p) $(DESTDIR)$(somedir) + # so it does not work when $(somedir) is undefined and + # $(DESTDIR) is not. + # To support the latter case, we have to write + # test -z "$(somedir)" || $(mkdir_p) $(DESTDIR)$(somedir), + # so the `.' trick is pointless. + mkdir_p='mkdir -p --' +else + # On NextStep and OpenStep, the `mkdir' command does not + # recognize any option. It will interpret all options as + # directories to create, and then abort because `.' already + # exists. + for d in ./-p ./--version; + do + test -d $d && rmdir $d + done + # $(mkinstalldirs) is defined by Automake if mkinstalldirs exists. + if test -f "$ac_aux_dir/mkinstalldirs"; then + mkdir_p='$(mkinstalldirs)' + else + mkdir_p='$(install_sh) -d' + fi +fi + for ac_prog in gawk mawk nawk awk do # Extract the first word of "$ac_prog", so it can be a program name with args. @@ -1417,7 +1484,7 @@ echo "$as_me:$LINENO: checking whether ${MAKE-make} sets \$(MAKE)" >&5 echo $ECHO_N "checking whether ${MAKE-make} sets \$(MAKE)... $ECHO_C" >&6 -set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y,./+-,__p_,'` +set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y,:./+-,___p_,'` if eval "test \"\${ac_cv_prog_make_${ac_make}_set+set}\" = set"; then echo $ECHO_N "(cached) $ECHO_C" >&6 else @@ -1453,7 +1520,7 @@ fi rmdir .tst 2>/dev/null - # test to see if srcdir already configured +# test to see if srcdir already configured if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then { { echo "$as_me:$LINENO: error: source directory already configured; run \"make distclean\" there first" >&5 @@ -1473,7 +1540,7 @@ # Define the identity of the package. PACKAGE='gccintro' - VERSION='1.0' + VERSION='1.1' cat >>confdefs.h <<_ACEOF @@ -1501,9 +1568,6 @@ MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"} - -AMTAR=${AMTAR-"${am_missing_run}tar"} - install_sh=${install_sh-"$am_aux_dir/install-sh"} # Installed binaries are usually stripped using `strip' when the user @@ -1596,6 +1660,13 @@ # We need awk for the "check" target. The system "awk" is bad on # some platforms. +# Always define AMTAR for backward compatibility. + +AMTAR=${AMTAR-"${am_missing_run}tar"} + +am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -' + + @@ -1628,13 +1699,13 @@ # `set' does not quote correctly, so add quotes (double-quote # substitution turns \\\\ into \\, and sed turns \\ into \). sed -n \ - "s/'/'\\\\''/g; - s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" + "s/'/'\\\\''/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" ;; *) # `set' quotes correctly as required by POSIX, so do not add quotes. sed -n \ - "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" + "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" ;; esac; } | @@ -1664,13 +1735,13 @@ # trailing colons and then remove the whole line if VPATH becomes empty # (actually we leave an empty line to preserve line numbers). if test "x$srcdir" = x.; then - ac_vpsub='/^[ ]*VPATH[ ]*=/{ + ac_vpsub='/^[ ]*VPATH[ ]*=/{ s/:*\$(srcdir):*/:/; s/:*\${srcdir}:*/:/; s/:*@srcdir@:*/:/; -s/^\([^=]*=[ ]*\):*/\1/; +s/^\([^=]*=[ ]*\):*/\1/; s/:*$//; -s/^[^=]*=[ ]*$//; +s/^[^=]*=[ ]*$//; }' fi @@ -1684,13 +1755,13 @@ cat >confdef2opt.sed <<\_ACEOF t clear : clear -s,^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*([^)]*)\)[ ]*\(.*\),-D\1=\2,g +s,^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*([^)]*)\)[ ]*\(.*\),-D\1=\2,g t quote -s,^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\),-D\1=\2,g +s,^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\),-D\1=\2,g t quote d : quote -s,[ `~#$^&*(){}\\|;'"<>?],\\&,g +s,[ `~#$^&*(){}\\|;'"<>?],\\&,g s,\[,\\&,g s,\],\\&,g s,\$,$$,g @@ -1712,7 +1783,7 @@ for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. ac_i=`echo "$ac_i" | - sed 's/\$U\././;s/\.o$//;s/\.obj$//'` + sed 's/\$U\././;s/\.o$//;s/\.obj$//'` # 2. Add them. ac_libobjs="$ac_libobjs $ac_i\$U.$ac_objext" ac_ltlibobjs="$ac_ltlibobjs $ac_i"'$U.lo' @@ -1756,9 +1827,10 @@ elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then set -o posix fi +DUALCASE=1; export DUALCASE # for MKS sh # Support unset when possible. -if (FOO=FOO; unset FOO) >/dev/null 2>&1; then +if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then as_unset=unset else as_unset=false @@ -1777,7 +1849,7 @@ LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ LC_TELEPHONE LC_TIME do - if (set +x; test -n "`(eval $as_var=C; export $as_var) 2>&1`"); then + if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then eval $as_var=C; export $as_var else $as_unset $as_var @@ -1956,16 +2028,17 @@ if mkdir -p . 2>/dev/null; then as_mkdir_p=: else + test -d ./-p && rmdir ./-p as_mkdir_p=false fi as_executable_p="test -f" # Sed expression to map a string onto a valid CPP name. -as_tr_cpp="sed y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g" +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. -as_tr_sh="sed y%*+%pp%;s%[^_$as_cr_alnum]%_%g" +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" # IFS @@ -1991,8 +2064,8 @@ } >&5 cat >&5 <<_CSEOF -This file was extended by gccintro $as_me 1.0, which was -generated by GNU Autoconf 2.57. Invocation command line was +This file was extended by gccintro $as_me 1.1, which was +generated by GNU Autoconf 2.59. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS @@ -2036,7 +2109,7 @@ -d, --debug don't remove temporary files --recheck update $as_me by reconfiguring in the same conditions --file=FILE[:TEMPLATE] - instantiate the configuration file FILE + instantiate the configuration file FILE Configuration files: $config_files @@ -2046,12 +2119,11 @@ cat >>$CONFIG_STATUS <<_ACEOF ac_cs_version="\\ -gccintro config.status 1.0 -configured by $0, generated by GNU Autoconf 2.57, +gccintro config.status 1.1 +configured by $0, generated by GNU Autoconf 2.59, with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\" -Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001 -Free Software Foundation, Inc. +Copyright (C) 2003 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." srcdir=$srcdir @@ -2245,14 +2317,17 @@ s,@AUTOMAKE@,$AUTOMAKE,;t t s,@AUTOHEADER@,$AUTOHEADER,;t t s,@MAKEINFO@,$MAKEINFO,;t t -s,@AMTAR@,$AMTAR,;t t s,@install_sh@,$install_sh,;t t s,@STRIP@,$STRIP,;t t s,@ac_ct_STRIP@,$ac_ct_STRIP,;t t s,@INSTALL_STRIP_PROGRAM@,$INSTALL_STRIP_PROGRAM,;t t +s,@mkdir_p@,$mkdir_p,;t t s,@AWK@,$AWK,;t t s,@SET_MAKE@,$SET_MAKE,;t t s,@am__leading_dot@,$am__leading_dot,;t t +s,@AMTAR@,$AMTAR,;t t +s,@am__tar@,$am__tar,;t t +s,@am__untar@,$am__untar,;t t s,@LIBOBJS@,$LIBOBJS,;t t s,@LTLIBOBJS@,$LTLIBOBJS,;t t CEOF @@ -2284,9 +2359,9 @@ (echo ':t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b' && cat $tmp/subs.frag) >$tmp/subs-$ac_sed_frag.sed if test -z "$ac_sed_cmds"; then - ac_sed_cmds="sed -f $tmp/subs-$ac_sed_frag.sed" + ac_sed_cmds="sed -f $tmp/subs-$ac_sed_frag.sed" else - ac_sed_cmds="$ac_sed_cmds | sed -f $tmp/subs-$ac_sed_frag.sed" + ac_sed_cmds="$ac_sed_cmds | sed -f $tmp/subs-$ac_sed_frag.sed" fi ac_sed_frag=`expr $ac_sed_frag + 1` ac_beg=$ac_end @@ -2304,21 +2379,21 @@ # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". case $ac_file in - | *:- | *:-:* ) # input from stdin - cat >$tmp/stdin - ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` - ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; + cat >$tmp/stdin + ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` + ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` - ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; + ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; * ) ac_file_in=$ac_file.in ;; esac # Compute @srcdir@, @top_srcdir@, and @INSTALL@ for subdirectories. ac_dir=`(dirname "$ac_file") 2>/dev/null || $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$ac_file" : 'X\(//\)[^/]' \| \ - X"$ac_file" : 'X\(//\)$' \| \ - X"$ac_file" : 'X\(/\)' \| \ - . : '\(.\)' 2>/dev/null || + X"$ac_file" : 'X\(//\)[^/]' \| \ + X"$ac_file" : 'X\(//\)$' \| \ + X"$ac_file" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || echo X"$ac_file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } /^X\(\/\/\)[^/].*/{ s//\1/; q; } @@ -2334,10 +2409,10 @@ as_dirs="$as_dir $as_dirs" as_dir=`(dirname "$as_dir") 2>/dev/null || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$as_dir" : 'X\(//\)[^/]' \| \ - X"$as_dir" : 'X\(//\)$' \| \ - X"$as_dir" : 'X\(/\)' \| \ - . : '\(.\)' 2>/dev/null || + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } /^X\(\/\/\)[^/].*/{ s//\1/; q; } @@ -2375,12 +2450,45 @@ ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_builddir$srcdir ;; esac -# Don't blindly perform a `cd "$ac_dir"/$ac_foo && pwd` since $ac_foo can be -# absolute. -ac_abs_builddir=`cd "$ac_dir" && cd $ac_builddir && pwd` -ac_abs_top_builddir=`cd "$ac_dir" && cd ${ac_top_builddir}. && pwd` -ac_abs_srcdir=`cd "$ac_dir" && cd $ac_srcdir && pwd` -ac_abs_top_srcdir=`cd "$ac_dir" && cd $ac_top_srcdir && pwd` + +# Do not use `cd foo && pwd` to compute absolute paths, because +# the directories may not exist. +case `pwd` in +.) ac_abs_builddir="$ac_dir";; +*) + case "$ac_dir" in + .) ac_abs_builddir=`pwd`;; + [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";; + *) ac_abs_builddir=`pwd`/"$ac_dir";; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_top_builddir=${ac_top_builddir}.;; +*) + case ${ac_top_builddir}. in + .) ac_abs_top_builddir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;; + *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_srcdir=$ac_srcdir;; +*) + case $ac_srcdir in + .) ac_abs_srcdir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;; + *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_top_srcdir=$ac_top_srcdir;; +*) + case $ac_top_srcdir in + .) ac_abs_top_srcdir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;; + *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;; + esac;; +esac case $INSTALL in @@ -2402,7 +2510,7 @@ configure_input="$ac_file. " fi configure_input=$configure_input"Generated from `echo $ac_file_in | - sed 's,.*/,,'` by configure." + sed 's,.*/,,'` by configure." # First look for the input files in the build tree, otherwise in the # src tree. @@ -2411,24 +2519,24 @@ case $f in -) echo $tmp/stdin ;; [\\/$]*) - # Absolute (can't be DOS-style, as IFS=:) - test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 + # Absolute (can't be DOS-style, as IFS=:) + test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 echo "$as_me: error: cannot find input file: $f" >&2;} { (exit 1); exit 1; }; } - echo $f;; + echo "$f";; *) # Relative - if test -f "$f"; then - # Build tree - echo $f - elif test -f "$srcdir/$f"; then - # Source tree - echo $srcdir/$f - else - # /dev/null tree - { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 + if test -f "$f"; then + # Build tree + echo "$f" + elif test -f "$srcdir/$f"; then + # Source tree + echo "$srcdir/$f" + else + # /dev/null tree + { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 echo "$as_me: error: cannot find input file: $f" >&2;} { (exit 1); exit 1; }; } - fi;; + fi;; esac done` || { (exit 1); exit 1; } _ACEOF diff -Naur -x '*.info' gccintro-1.0/configure.ac gccintro-1.1/configure.ac --- gccintro-1.0/configure.ac 2004-05-06 14:28:26.000000000 +0100 +++ gccintro-1.1/configure.ac 2005-08-20 11:51:54.000000000 +0100 @@ -1,4 +1,4 @@ -AC_INIT(gccintro,1.0) +AC_INIT(gccintro,1.1) AC_CONFIG_SRCDIR(gccintro.texi) AM_INIT_AUTOMAKE([no-dependencies]) AC_OUTPUT(Makefile) diff -Naur -x '*.info' gccintro-1.0/COPYING.FDL gccintro-1.1/COPYING.FDL --- gccintro-1.0/COPYING.FDL 2003-03-03 17:05:55.000000000 +0000 +++ gccintro-1.1/COPYING.FDL 2005-07-21 10:46:59.000000000 +0100 @@ -3,7 +3,7 @@ Copyright (C) 2000,2001,2002 Free Software Foundation, Inc. - 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. diff -Naur -x '*.info' gccintro-1.0/dtestval2.c gccintro-1.1/dtestval2.c --- gccintro-1.0/dtestval2.c 2003-10-11 13:31:00.000000000 +0100 +++ gccintro-1.1/dtestval2.c 2005-08-07 18:06:28.000000000 +0100 @@ -3,6 +3,6 @@ int main (void) { - printf("Value of NUM is %d\n", 2+2); + printf ("Value of NUM is %d\n", 2+2); return 0; } diff -Naur -x '*.info' gccintro-1.0/dtestval.c gccintro-1.1/dtestval.c --- gccintro-1.0/dtestval.c 2003-10-11 13:27:59.000000000 +0100 +++ gccintro-1.1/dtestval.c 2005-08-07 18:06:27.000000000 +0100 @@ -3,6 +3,6 @@ int main (void) { - printf("Value of NUM is %d\n", NUM); + printf ("Value of NUM is %d\n", NUM); return 0; } diff -Naur -x '*.info' gccintro-1.0/fdl.texi gccintro-1.1/fdl.texi --- gccintro-1.0/fdl.texi 2004-04-07 15:41:26.000000000 +0100 +++ gccintro-1.1/fdl.texi 2005-07-21 10:46:32.000000000 +0100 @@ -1,10 +1,9 @@ -@cindex FDL, GNU Free Documentation License @center Version 1.2, November 2002 @smallerfonts @rm @display Copyright @copyright{} 2000,2001,2002 Free Software Foundation, Inc. -59 Temple Place, Suite 330, Boston, MA 02111-1307, USA +51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. diff -Naur -x '*.info' gccintro-1.0/fptest2.c gccintro-1.1/fptest2.c --- gccintro-1.0/fptest2.c 1970-01-01 01:00:00.000000000 +0100 +++ gccintro-1.1/fptest2.c 2005-07-21 10:33:11.000000000 +0100 @@ -0,0 +1,24 @@ +#include + +void +set_fpu (unsigned int mode) +{ + asm ("fldcw %0" : : "m" (*&mode)); +} + +int +main (void) +{ + double a = 3.0, b = 7.0, c; +#ifdef DOUBLE + set_fpu (0x27F); /* use double-precision rounding */ +#endif + c = a / b; + + if (c == a / b) { + printf ("comparison succeeds\n"); + } else { + printf ("unexpected result\n"); + } + return 0; +} diff -Naur -x '*.info' gccintro-1.0/gccintro.texi gccintro-1.1/gccintro.texi --- gccintro-1.0/gccintro.texi 2004-05-06 14:33:47.000000000 +0100 +++ gccintro-1.1/gccintro.texi 2005-08-20 17:25:44.000000000 +0100 @@ -1,7 +1,7 @@ \input texinfo.tex @c -*- texinfo -*- @c -*-texinfo-*- @c This is the texinfo source for the manual "An Introduction to GCC". -@c Copyright (C) 2003, 2004 Network Theory Ltd +@c Copyright (C) 2003, 2004, 2005 Network Theory Ltd @c See the file COPYING.FDL for copying conditions. @c @include config-local.texi @@ -19,6 +19,7 @@ @titlepage @title An Introduction to GCC @subtitle for the GNU Compilers @code{gcc} and @code{g++} +@subtitle Revised and updated @author Brian Gough @author Foreword by Richard M.@: Stallman @page @@ -27,6 +28,7 @@ @flushleft A catalogue record for this book is available from the British Library. +Second printing, August 2005 (1/8/2005). Revised and updated. First printing, March 2004 (7/3/2004). Published by Network Theory Limited. @@ -54,7 +56,7 @@ industry. @vskip 1ex @end ifset -Copyright @copyright{} 2004 Network Theory Ltd. +Copyright @copyright{} 2004, 2005 Network Theory Ltd. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or @@ -72,21 +74,19 @@ @code{http://www.network-theory.co.uk/gcc/intro/src/} @end titlepage -@ifnottex -@node Top -@top An Introduction to GCC -@end ifnottex - @contents @ifinfo +@node Top +@top An Introduction to GCC + This manual provides an introduction to the GNU C and C++ Compilers, @code{gcc} and @code{g++}, which are part of the GNU Compiler Collection (GCC). -The development of this manual was funded entirely by Network Theory -Ltd. Copies published by Network Theory Ltd raise money for more free -documentation. +The development of this manual was funded entirely by +@uref{http://www.network-theory.co.uk/,Network Theory Ltd}. Copies +published by Network Theory Ltd raise money for more free documentation. @end ifinfo @menu @@ -102,10 +102,13 @@ * Compiler-related tools:: * How the compiler works:: * Examining compiled files:: +* Common error messages:: * Getting help:: * Further reading:: * Acknowledgements:: -* Index:: +* Other books from the publisher:: +* Free software organizations:: +* Index:: @end menu @ifnotinfo @@ -147,7 +150,7 @@ The original author of the GNU C Compiler (GCC) is Richard Stallman, the founder of the GNU Project. -The GNU project was started in 1984 to create a complete Unix-like +The GNU Project was started in 1984 to create a complete Unix-like operating system as free software, in order to promote freedom and cooperation among computer users and programmers. Every Unix-like operating system needs a C compiler, and as there were no free compilers @@ -240,7 +243,7 @@ @cindex Scheme, compared with C/C++ @cindex Java, compared with C/C++ @cindex C/C++, risks of using -@cindex risks, when using C/C++ +@cindex risks, examples of C and C++ are languages that allow direct access to the computer's memory. Historically, they have been used for writing low-level systems software, and applications where high-performance or control over @@ -339,6 +342,7 @@ * Compiling multiple source files:: * Compiling files independently:: * Recompiling and relinking:: +* A simple makefile:: * Linking with external libraries:: * Using library header files:: @end menu @@ -433,8 +437,8 @@ @option{-Wall} produces the following message: @cindex warning, format with different type arg -@cindex format, @samp{different type arg} warning -@cindex @code{different type arg}, format warning +@cindex format, different type arg warning +@cindex different type arg, format warning @example $ gcc -Wall bad.c -o bad @@ -450,10 +454,10 @@ @dfn{warning messages} which indicate possible problems (but do not stop the program from compiling). -In this case, the correct format specifier would have been @samp{%d} (the -allowed format specifiers for @code{printf} can be found in any general -book on C, such as the @cite{GNU C Library Reference Manual}, -@pxref{Further reading}). +In this case, the correct format specifier should be @samp{%d} +for an integer argument. The allowed format specifiers for +@code{printf} can be found in any general book on C, such as the +@cite{GNU C Library Reference Manual} (@pxref{Further reading}). Without the warning option @option{-Wall} the program appears to compile cleanly, but produces incorrect results: @@ -465,8 +469,8 @@ Two plus two is 2.585495 @r{(incorrect output)} @end example @noindent -@cindex C/C++, risks of using, example -@cindex risks, example of corrupted output +@cindex C/C++, risks of using +@cindex risks, examples of The incorrect format specifier causes the output to be corrupted, because the function @code{printf} is passed an integer instead of a floating-point number. Integers and floating-point numbers are stored @@ -476,7 +480,7 @@ Clearly, it is very dangerous to develop a program without checking for compiler warnings. If there are any functions which are not used -correctly they can cause the program to crash, or to produce incorrect +correctly they can cause the program to crash or produce incorrect results. Turning on the compiler warning option @option{-Wall} will catch many of the commonest errors which occur in C programming. @@ -595,7 +599,7 @@ In the second stage, the object files are merged together by a separate program called the @dfn{linker}. The linker combines all the -object files together to create a single executable. +object files to create a single executable. An object file contains machine code where any references to the memory addresses of functions (or variables) in other files are left undefined. @@ -606,7 +610,6 @@ @menu * Creating object files from source files:: * Creating executables from object files:: -* Link order of object files:: @end menu @node Creating object files from source files @@ -643,7 +646,7 @@ Note that there is no need to use the option @option{-o} to specify the name of the output file in this case. When compiling with @option{-c} the compiler automatically creates an object file whose name is the same -as the source file, with @file{.o} instead of the original extension. +as the source file, but with @file{.o} instead of the original extension. @cindex header file, not compiled There is no need to put the header file @file{hello.h} on the command @@ -695,54 +698,13 @@ It produces the same output as the version of the program using a single source file in the previous section. -@node Link order of object files -@subsection Link order of object files - -@cindex link order, of object files -@cindex link order, from left to right -@cindex object files, link order -@cindex order, of object files in linking -On Unix-like systems, the traditional behavior of compilers and linkers -is to search for external functions from left to right in the object -files specified on the command line. This means that the object file -which contains the definition of a function should appear after any -files which call that function. - -In this case, the file @file{hello_fn.o} containing the function -@code{hello} should be specified after @file{main.o} itself, since -@code{main} calls @code{hello}: - -@example -$ gcc main.o hello_fn.o -o hello @r{(correct order)} -@end example -@noindent -With some compilers or linkers the opposite ordering would result in an error, -@cindex error, undefined reference due to order of object files -@cindex undefined reference error, due to order of object files - -@example -$ cc hello_fn.o main.o -o hello @r{(incorrect order)} -main.o: In function `main': -main.o(.text+0xf): undefined reference to `hello' -@end example -@noindent -because there is no object file containing @code{hello} after -@file{main.o}. - -Most current compilers and linkers will search all object files, -regardless of order, but since not all compilers do this it is best to -follow the convention of ordering object files from left to right. - -This is worth keeping in mind if you ever encounter unexpected problems -with undefined references, and all the necessary object files appear to -be present on the command line. @node Recompiling and relinking @section Recompiling and relinking @cindex recompiling modified source files -@cindex relinking, updated object files +@cindex relinking updated object files @cindex modified source files, recompiling @cindex updated object files, relinking @cindex source files, recompiling @@ -763,7 +725,7 @@ $ gcc -Wall -c main.c @end example @noindent -@cindex recompiling +@cindex recompiling modified source files @cindex modified source files, recompiling @cindex updated source files, recompiling This produces a new object file @file{main.o}. There is no need to @@ -771,7 +733,7 @@ related files that it depends on, such as header files, have not changed. -@cindex relinking +@cindex relinking updated object files @cindex linking, updated object files The new object file can be relinked with the @code{hello} function to create a new executable file: @@ -797,11 +759,123 @@ necessary to modify and recompile all of the other source files which use it.} -In general, linking is faster than compilation---in a large project -with many source files, recompiling only those that have been modified -can make a significant saving. The process of recompiling only the -modified files in a project can be automated using @cite{GNU Make} -(@pxref{Further reading}). +In a large project with many source files, recompiling only those that +have been modified can make a significant saving. The process of +recompiling only the modified files in a project can be automated with +the standard Unix program @code{make}. + +@node A simple makefile +@section A simple makefile +@cindex makefile, example of +@cindex GNU Make + +For those unfamiliar with @code{make}, this section provides a simple +demonstration of its use. Make is a program in its own right and can be +found on all Unix systems. To learn more about the GNU version of +@code{make} you will need to consult the @cite{GNU Make} manual by +Richard M. Stallman and Roland McGrath (@pxref{Further reading}). + +@cindex target, in makefile +@cindex dependency, in makefile +@cindex command, in makefile +Make reads a description of a project from a @dfn{makefile} (by default, +called @file{Makefile} in the current directory). A makefile specifies +a set of compilation rules in terms of @dfn{targets} (such as +executables) and their @dfn{dependencies} (such as object files and +source files) in the following format: + +@example +@i{target}: @i{dependencies} + @i{command} +@end example +@noindent +@cindex tab, in makefiles +@cindex separator, in makefiles +For each target, make checks the modification time of the corresponding +dependency files to determine whether the target needs to +be rebuilt using the corresponding command. Note that the +@code{@i{command}} lines in a makefile must be indented with a single +@key{TAB} character, not spaces. + +@cindex implicit rules, in makefile +@cindex rules, in makefile +@cindex @code{CFLAGS}, make variable +@cindex @code{CC}, make variable +@cindex @code{CXX}, make variable +@cindex @code{CXXFLAGS}, make variable +@cindex @code{CPPFLAGS}, make variable +@cindex variables, in make +GNU Make contains many default rules, referred to as @dfn{implicit} +rules, to simplify the construction of makefiles. For example, these +specify that @file{.o} files can be obtained from @file{.c} files by +compilation, and that an executable can be made by linking together +@file{.o} files. Implicit rules are defined in terms of @dfn{make +variables}, such as @code{CC} (the C compiler) and @code{CFLAGS} (the +compilation options for C programs), which can be set using +@code{@i{VARIABLE}=@i{VALUE}} lines in the makefile. For C++ the +equivalent variables are @code{CXX} and @code{CXXFLAGS}, while the make +variable @code{CPPFLAGS} sets the preprocessor options. The implicit and +user-defined rules are automatically chained together as necessary by +GNU Make. + +@need 1000 +A simple @file{Makefile} for the project above can be written as +follows: + +@example +@verbatiminclude c1makefile2 +@end example +@noindent +The file can be read like this: using the C compiler @command{gcc}, +with compilation option @option{-Wall}, build the target executable +@code{main} from the object files @file{main.o} and @file{hello_fn.o} +(these, in turn, will be built via implicit rules from @file{main.c} +and @file{hello_fn.c}). The target @code{clean} has no dependencies +and simply removes all the compiled files.@footnote{This assumes that +there is no file called @file{clean} in the current directory---see +the discussion of ``phony targets'' in the GNU Make manual for +details.} The option @option{-f} (force) on the @command{rm} command +suppresses any error messages if the files do not exist. + +To use the makefile, type @command{make}. When called with no arguments, +the first target in the makefile is built, producing the executable +@file{main}: + +@example +$ make +gcc -Wall -c -o main.o main.c +gcc -Wall -c -o hello_fn.o hello_fn.c +gcc main.o hello_fn.o -o main +$ ./main +Hello, world! +@end example +@noindent +To rebuild the executable after modifying a source file, simply type +@command{make} again. By checking the timestamps of the target and dependency files, +make identifies the files which have changed and regenerates the corresponding +intermediate files needed to update the targets: + +@example +$ emacs main.c @r{(edit the file)} +$ make +gcc -Wall -c -o main.o main.c +gcc main.o hello_fn.o -o main +$ ./main +Hello, everyone! +@end example +@noindent +Finally, to remove the generated files, type @command{make clean}: + +@example +$ make clean +rm -f main main.o hello_fn.o +@end example +@noindent +A more sophisticated makefile would usually contain additional targets +for installation (@code{make install}) and testing (@code{make check}). + +The examples in the rest of this book are small enough not to need +makefiles, but the use of make is recommended for any larger programs. @node Linking with external libraries @section Linking with external libraries @@ -864,7 +938,7 @@ @noindent Trying to create an executable from this source file alone causes the compiler to give an error at the link stage: -@cindex undefined reference, due to missing library +@cindex undefined reference error @cindex reference, undefined due to missing library @cindex libraries, link error due to undefined reference @@ -917,7 +991,7 @@ @cindex linking, with library using @option{-l} -@cindex libraries, linking with using @option{-l} +@cindex libraries, linking with @cindex @option{-l} option, linking with libraries @cindex @option{-lm} option, link with math library @cindex @option{l} option, linking with libraries @@ -950,18 +1024,19 @@ @cindex libraries, link order @cindex link order, of libraries @cindex link order, from left to right -The ordering of libraries on the command line follows the same -convection as for object files: they are searched from left to right---a -library containing the definition of a function should appear after any -source files or object files which use it. This includes libraries -specified with the short-cut @option{-l} option, as shown in the -following command: + +The traditional behavior of linkers is to search for +external functions from left to right in the libraries specified on the +command line. This means that a library containing the definition of a +function should appear after any source files or object files which use +it. This includes libraries specified with the short-cut @option{-l} +option, as shown in the following command: @example $ gcc -Wall calc.c -lm -o calc @r{(correct order)} @end example @noindent -With some compilers the opposite ordering (placing the @option{-lm} +With some linkers the opposite ordering (placing the @option{-lm} option before the file which uses it) would result in an error, @example @@ -970,7 +1045,7 @@ main.o(.text+0xf): undefined reference to `sqrt' @end example @noindent -@cindex undefined reference error, due to library link order +@cindex undefined reference error @cindex error, undefined reference due to library link order @cindex linking, undefined reference error due to library link order because there is no library or object file containing @code{sqrt} after @@ -1007,9 +1082,13 @@ @c because there is no library containing mathematical functions used by @c @file{libglpk.a} (such as @code{exp}) after the @option{-lglpk} option. -As for object files, most current compilers will search all libraries, -regardless of order. However, since not all compilers do this it is best -to follow the convention of ordering libraries from left to right. +Most current linkers will search all libraries, regardless +of order, but since some do not do this it is best to follow the +convention of ordering libraries from left to right. + +This is worth keeping in mind if you ever encounter unexpected problems +with undefined references, and all the necessary libraries appear to be +present on the command line. @node Using library header files @section Using library header files @@ -1049,7 +1128,7 @@ Two cubed is 2.851120 @r{(incorrect result, should be 8)} @end example @noindent -@cindex C/C++, risks of using, example +@cindex C/C++, risks of using The results are corrupted because the arguments and return value of the call to @code{pow} are passed with incorrect types.@footnote{The actual output shown above may differ, depending on the specific platform and @@ -1063,8 +1142,7 @@ function `pow' @end example @noindent -@cindex @code{implicit declaration of function} warning, due to missing header file -@cindex warnings, implicit declaration of function +@cindex implicit declaration of function @cindex header file, missing header causes implicit declaration @cindex missing header file, causes implicit declaration @c The error is now detected and can be fixed by adding the line @@ -1089,6 +1167,7 @@ * C language standards:: * Warning options in -Wall:: * Additional warning options:: +* Recommended warning options:: @end menu @node Setting search paths @@ -1102,8 +1181,8 @@ A common problem when compiling a program using library header files is the error: -@cindex @code{No such file or directory}, header file not found -@cindex header file, not found---compilation error @code{no such file or directory} +@cindex No such file or directory, header file not found +@cindex header file, not found @example @var{FILE.h}: No such file or directory @@ -1112,8 +1191,8 @@ This occurs if a header file is not present in the standard include file directories used by @code{gcc}. A similar problem can occur for libraries: -@cindex @code{cannot find @var{library}}, linker error -@cindex linker error, @code{cannot find @var{library}} +@cindex cannot find @var{library} error +@cindex linkr error, cannot find library @example /usr/bin/ld: cannot find @var{library} @@ -1212,7 +1291,7 @@ However, if GDBM has been installed in a different location, trying to compile the program will give the following error: -@cindex @code{No such file or directory}, header file not found +@cindex No such file or directory, header file not found @example $ gcc -Wall dbmain.c -lgdbm @@ -1229,7 +1308,7 @@ which is not part of the default @code{gcc} include path. Adding the appropriate directory to the include path with the command-line option @option{-I} allows the program to be compiled, but not linked: -@cindex @code{cannot find -l@var{library}} error, example of +@cindex cannot find @var{library} error @example $ gcc -Wall -I/opt/gdbm-1.8.3/include dbmain.c -lgdbm @@ -1276,10 +1355,12 @@ The search paths for header files and libraries can also be controlled through environment variables in the shell. These may be set automatically for each session using the appropriate login file, such as -@file{.bash_profile}. +@file{.bash_profile} in the case of GNU Bash. @cindex @code{bash} profile file, login settings @cindex include path, setting with environment variables +@cindex C include path +@cindex C++ include path @cindex @env{C_INCLUDE_PATH} @cindex @env{CPLUS_INCLUDE_PATH} Additional directories can be added to the include path using the @@ -1292,14 +1373,21 @@ $ export C_INCLUDE_PATH @end example @noindent +and similarly for C++ programs: +@example +$ CPLUS_INCLUDE_PATH=/opt/gdbm-1.8.3/include +$ export CPLUS_INCLUDE_PATH +@end example +@noindent This directory will be searched after any directories specified on the command line with the option @option{-I}, -and before the standard default directories @file{/usr/local/include} -and @file{/usr/include}. The shell command @code{export} is needed to +and before the standard default directories (such as @file{/usr/local/include} +and @file{/usr/include}). The shell command @code{export} is needed to make the environment variable available to programs outside the shell itself, such as the compiler---it is only needed once for each variable in each shell session, and can also be set in the appropriate login -file. +file.@footnote{In GNU Bash, the shorter form @code{export @var{VARIABLE}=@var{VALUE}} +is also allowed.} Similarly, additional directories can be added to the link path using the environment variable @env{LIBRARY_PATH}. For example, the following @@ -1313,7 +1401,7 @@ @noindent This directory will be searched after any directories specified on the command line with the option @option{-L}, and before the standard -default directories @file{/usr/local/lib} and @file{/usr/lib}. +default directories (such as @file{/usr/local/lib} and @file{/usr/lib}). With the environment variable settings given above the program @file{dbmain.c} can be compiled without the @option{-I} and @option{-L} @@ -1324,7 +1412,9 @@ @end example @noindent because the default paths now use the directories specified in the -environment variables @env{C_INCLUDE_PATH} and @env{LIBRARY_PATH}. +environment variables @env{C_INCLUDE_PATH} and @env{LIBRARY_PATH}. The +same compilation command with @code{g++} would use the environment +variables @env{CPLUS_INCLUDE_PATH} and @env{LIBRARY_PATH}. @c Note @c that these defaults are in addition to the system directories @@ -1361,6 +1451,9 @@ $ LIBRARY_PATH=.:/opt/gdbm-1.8.3/lib:/net/lib @end example @noindent +For C++ programs, use the environment variable @env{CPLUS_INCLUDE_PATH} +instead of @env{C_INCLUDE_PATH}. + To specify multiple search path directories on the command line, the options @option{-I} and @option{-L} can be repeated. For example, the following command, @@ -1377,7 +1470,7 @@ @enumerate @item command-line options @option{-I} and @option{-L}, from left to right -@item directories specified by environment variables, such as @env{C_INCLUDE_PATH} and @env{LIBRARY_PATH} +@item directories specified by environment variables, such as @env{C_INCLUDE_PATH} (for C programs), @env{CPLUS_INCLUDE_PATH} (for C++ programs) and @env{LIBRARY_PATH} @item default system directories @end enumerate @noindent @@ -1394,8 +1487,8 @@ If an attempt is made to start the executable directly, the following error will occur on most systems: -@cindex error, while loading shared libraries -@cindex @code{cannot open shared object file} error +@cindex error while loading shared libraries +@cindex cannot open shared object file @cindex shared libraries, error while loading @cindex libraries, error while loading shared library @@ -1507,7 +1600,7 @@ @cindex login file, setting environment variables in @cindex profile file, setting environment variables in To save typing, the @env{LD_LIBRARY_PATH} environment variable can be -set once for each session in the appropriate login file, such as +set automatically for each session using the appropriate login file, such as @file{.bash_profile} for the GNU Bash shell. @cindex @code{bash} profile file, login settings @@ -1517,7 +1610,7 @@ the following command sets the load path to use the @file{lib} directories under @file{/opt/gdbm-1.8.3} and @file{/opt/gtk-1.4}: @cindex environment variables, extending an existing path -@cindex paths, extending an existing path in an environment variable +@cindex paths, extending environment variable @example $ LD_LIBRARY_PATH=/opt/gdbm-1.8.3/lib:/opt/gtk-1.4/lib @@ -1595,7 +1688,7 @@ @cindex @option{-ansi} option, disable language extensions @cindex @option{ansi} option, disable language extensions @cindex @option{-pedantic} option, conform to the ANSI standard (with @option{-ansi}) -@cindex @option{pedantic} option, conform to the ANSI standard (with @option{-ansi}) +@cindex @option{pedantic} option @cindex @option{-std} option, select specific language standard @cindex @option{std} option, select specific language standard @@ -1623,7 +1716,7 @@ Occasionally a valid ANSI/ISO program may be incompatible with the extensions in GNU C. To deal with this situation, the compiler option -@option{-ansi} disables those GNU extensions which conflict with the +@option{-ansi} disables those GNU extensions which are in conflict with the ANSI/ISO standard. On systems using the GNU C Library (@code{glibc}) it also disables extensions to the C standard library. This allows programs written for ANSI/ISO C to be compiled without any unwanted @@ -1642,7 +1735,7 @@ C functions). Consequently, it cannot be used as a variable name without giving a compilation error: @cindex keywords, additional in GNU C -@cindex @code{parse error}, due to language extensions +@cindex parse error due to language extensions @example $ gcc -Wall ansi.c @@ -1665,7 +1758,7 @@ extensions are @code{asm}, @code{inline}, @code{typeof}, @code{unix} and @code{vax}. More details can be found in the GCC Reference Manual ``@cite{Using GCC}'' (@pxref{Further reading}). -@cindex @code{asm}, GNU C extension keyword +@cindex @code{asm} extension keyword @cindex @code{typeof}, GNU C extension keyword @cindex @code{unix}, GNU C extension keyword @cindex @code{vax}, GNU C extension keyword @@ -1682,7 +1775,7 @@ The constant @code{M_PI} is not part of the ANSI/ISO C standard library (it comes from the BSD version of Unix). In this case, the program will not compile with the @option{-ansi} option: -@cindex @code{undeclared identifier} error for C library, when using @option{-ansi} option +@cindex undeclared identifier error for C library, when using @option{-ansi} option @example $ gcc -Wall -ansi pi.c @@ -1731,12 +1824,12 @@ The @w{@code{_GNU_SOURCE}} macro enables all the extensions together, with the POSIX extensions taking precedence over the others in cases where they conflict. Further information about feature test macros can -be found in the @cite{GNU C Library Reference Manual}, @pxref{Further -reading}. +be found in the @cite{GNU C Library Reference Manual} (@pxref{Further +reading}). @node Strict ANSI/ISO @subsection Strict ANSI/ISO -@cindex @option{pedantic} option, ANSI/ISO C +@cindex @option{pedantic} option @cindex ANSI/ISO C, pedantic diagnostics option @cindex strict ANSI/ISO C, @option{-pedantic} option The command-line option @option{-pedantic} in combination with @option{-ansi} @@ -1747,8 +1840,8 @@ Here is a program which uses variable-size arrays, a GNU C extension. The array @code{x[n]} is declared with a length specified by the integer variable @code{n}. -@cindex variable-size arrays in GNU C -@cindex arrays, variable-size in GNU C +@cindex variable-size arrays +@cindex arrays, variable-size @example @verbatiminclude gnuarray.c @@ -1764,7 +1857,6 @@ @noindent However, compiling with @option{-ansi -pedantic} reports warnings about violations of the ANSI/ISO standard: -@cindex variable-size array, forbidden in ANSI/ISO C @example $ gcc -Wall -ansi -pedantic gnuarray.c @@ -1860,7 +1952,7 @@ not agree with the type of the corresponding function argument. @item @option{-Wunused} @r{(included in @option{-Wall})} -@cindex unused variable warning, @option{-Wunused} +@cindex unused variable warning @cindex @option{-Wunused} option, unused variable warning @cindex @option{Wunused} option, unused variable warning This option warns about unused variables. When a variable is declared @@ -1871,7 +1963,7 @@ @item @option{-Wimplicit} @r{(included in @option{-Wall})} @cindex @option{-Wimplicit} option, warn about missing declarations @cindex @option{Wimplicit} option, warn about missing declarations -@cindex implicit declaration warning +@cindex implicit declaration of function @cindex missing prototypes warning @cindex prototypes, missing This option warns about any functions that are used without being @@ -1917,7 +2009,7 @@ @cindex additional warning options @cindex warning options, additional GCC provides many other warning options that are not included in -@option{-Wall}, but are often useful. Typically these produce warnings +@option{-Wall} but are often useful. Typically these produce warnings for source code which may be technically valid but is very likely to cause problems. The criteria for these options are based on experience of common errors---they are not included in @option{-Wall} because @@ -1953,7 +2045,7 @@ @end example @noindent but does give a warning with @option{-W}: -@cindex @code{comparison of ... expression always true/false} warning, example of +@cindex comparison of expression always true/false warning @example $ gcc -W -c w.c @@ -1973,8 +2065,41 @@ @cindex @option{-Wconversion} option, warn about type conversions @cindex @option{Wconversion} option, warn about type conversions This option warns about implicit type conversions that could cause -unexpected results. For example, the assignment of a negative value to -an unsigned variable, as in the following code, +unexpected results, such as conversions between floating-point and +integer types, between signed and unsigned types and between types of +different width (e.g. long and short integers). Conversions can occur +in expressions and assignments, and in calls to functions if the +types of the arguments do not match those specified in the prototype. + +For example, the integer absolute value function @code{int abs(int i)} +is easily confused with the corresponding floating-point function +@code{double fabs(double x)}. This can lead to incorrect results, as +shown in the following program: + +@example +@verbatiminclude wabs.c +@end example +@noindent +Compiling this function with @option{-Wall} does not produce a warning, + +@example +$ gcc -Wall wabs.c +$ ./a.out +x = -3.14 |x| = 3 @r{(incorrect)} +@end example +@noindent +but does give a warning with @option{-Wconversion}: + +@example +gcc -Wall -Wconversion wabs.c +wabs.c: In function `main': +wabs.c:8: warning: passing arg 1 of `abs' as +integer rather than floating due to prototype +@end example + +The @option{-Wconversion} option also catches errors such as the +assignment of a negative value to an unsigned variable, as in the +following code, @example unsigned int x = -1; @@ -1983,13 +2108,13 @@ @cindex casts, used to avoid conversion warnings @cindex unsigned integer, casting @cindex signed integer, casting -is technically allowed by the ANSI/ISO C standard (with the negative -integer being converted to a positive integer, according to the machine -representation) but could be a simple programming error. If you need to -perform such a conversion you can use an explicit cast, such as -@code{((unsigned int) -1)}, to avoid any warnings from this option. On -two's-complement machines the result of the cast gives the maximum -number that can be represented by an unsigned integer. +This is technically allowed by the ANSI/ISO C standard (with the +negative integer being converted to a positive integer, according to the +machine representation) but could be a simple programming error. If you +need to perform such a conversion you can use an explicit cast, such as +@code{(unsigned int)-1}, to avoid any warnings from this option. On +two's-complement machines the cast of @math{-1} gives the maximum number +that can be represented by an unsigned integer. @item @option{-Wshadow} @cindex shadowing of variables @@ -2081,6 +2206,20 @@ option changes the default behavior by converting warnings into errors, stopping the compilation whenever a warning occurs. +@node Recommended warning options +@section Recommended warning options + +The following options are a good choice for finding problems in C and +C++ programs: + +@example +$ gcc -ansi -pedantic -Wall -W -Wconversion + -Wshadow -Wcast-qual -Wwrite-strings +@end example +@noindent +While this list is not exhaustive, regular use of these options will +catch many common errors. + @node Using the preprocessor @chapter Using the preprocessor @cindex @code{cpp}, C preprocessor @@ -2107,18 +2246,18 @@ @cindex @code{#ifdef}, preprocessor directive The following program demonstrates the most common use of the C preprocessor. It uses the preprocessor conditional @code{#ifdef} to -check whether a macro is defined. +check whether a macro is defined: +@example +@verbatiminclude dtest.c +@end example +@noindent When the macro is defined, the preprocessor includes the corresponding code up to the closing @code{#endif} command. In this example, the macro which is tested is called @code{TEST}, and the conditional part of the source code is a @code{printf} statement which prints the message -``@code{Test mode}'': +``@code{Test mode}''. -@example -@verbatiminclude dtest.c -@end example -@noindent The @code{gcc} option @option{-D@var{NAME}} defines a preprocessor macro @code{NAME} from the command line. If the program above is compiled with the command-line option @option{-DTEST}, the macro @code{TEST} will @@ -2181,7 +2320,7 @@ @cindex value, of macro @cindex macros, defined with value -In addition to being defined, a macro can also be given a concrete +In addition to being defined, a macro can also be given a value. This value is inserted into the source code at each point where the macro occurs. The following program uses a macro @code{NUM}, to represent a number which will be printed: @@ -2263,7 +2402,7 @@ @end example @noindent @cindex quotes, for defining empty macro -A macro can be defined to a empty value using quotes on the command line, +A macro can be defined with an empty value using quotes on the command line, @code{-D@var{NAME}=""}. Such a macro is still treated as @i{defined} by conditionals such as @code{#ifdef}, but expands to nothing. @cindex empty macro, compared with undefined macro @@ -2271,11 +2410,12 @@ A macro containing quotes can be defined using shell-escaped quote characters. For example, the command-line option -@code{-DMESSAGE="\"Hello, World!\""} defines a macro @code{MESSAGE} -which expands to the sequence of characters @code{"Hello, World!"}. For -an explanation of the different types of quoting and escaping used in -the shell see the ``@cite{GNU Bash Reference Manual}'', @ref{Further -reading}. +@code{-DMESSAGE='"Hello, World!"'} defines a macro @code{MESSAGE} which +expands to the sequence of characters @code{"Hello, World!"}. The outer +shell-quotes @code{'...'} protect the C-quotes of the string +@code{"Hello, World!"}. For an explanation of the different types of +quoting and escaping used in the shell see the ``@cite{GNU Bash +Reference Manual}'', @ref{Further reading}. @cindex shell quoting @@ -2283,7 +2423,7 @@ @section Preprocessing source files @cindex @option{-E} option, preprocess source files @cindex @option{E} option, preprocess source files -@cindex preprocessing, source files +@cindex preprocessing source files, @option{-E} option It is possible to see the effect of the preprocessor on source files directly, using the @option{-E} option of @code{gcc}. For example, the @@ -2390,49 +2530,57 @@ debugging, since there is no easy way to find the cause of an error if the program crashes. -@cindex @code{gdb}, GNU debugger +@cindex @code{gdb} @cindex debugging, with @code{gdb} +@cindex GNU debugger, @code{gdb} @cindex symbol table @cindex executable, symbol table stored in GCC provides the @option{-g} @dfn{debug option} to store additional debugging information in object files and executables. This debugging information allows errors to be traced back from a specific machine -instruction to the corresponding line in the original source file. It -also allows the execution of a program to be traced in a debugger, such -as the GNU Debugger @code{gdb} (for more information, see +instruction to the corresponding line in the original source file. The +execution of a program compiled with @option{-g} can also be followed in a +debugger, such as the GNU Debugger @code{gdb} (for more information, see ``@cite{Debugging with GDB: The GNU Source-Level Debugger}'', -@ref{Further reading}). Using a debugger also allows the values of +@ref{Further reading}). Using a debugger allows the values of variables to be examined while the program is running. -The debug option works by storing the names of functions and variables -(and all the references to them), with their corresponding source code -line-numbers, in a @dfn{symbol table} in object files and executables. +The debug compilation option works by storing the names and source +code line-numbers of functions and variables in a @dfn{symbol table} +in the object file or executable. @menu * Examining core files:: * Displaying a backtrace:: +* Setting a breakpoint:: +* Stepping through the program:: +* Modifying variables:: +* Continuing execution:: +* More information about GDB:: @end menu @node Examining core files @section Examining core files -@cindex core file, examining from program crash +@cindex core file, examining @cindex crashes, saved in core file @cindex program crashes, saved in core file @cindex examining core files -In addition to allowing a program to be run under the debugger, another -helpful application of the @option{-g} option is to find the -circumstances of a program crash. +In addition to allowing programs to be run under the debugger, an +important benefit of the @option{-g} option is the ability to examine +the cause of a program crash from a ``core dump''. @cindex termination, abnormal (@code{core dumped}) -When a program exits abnormally the operating system can write out a -@dfn{core file}, usually named @file{core}, which contains the in-memory -state of the program at the time it crashed. Combined with information -from the symbol table produced by @option{-g}, the core file can be used -to find the line where the program stopped, and the values of its -variables at that point. +When a program exits abnormally (i.e. crashes) the operating system can +write out a @dfn{core file} (usually named @file{core}) which contains +the in-memory state of the program at the time it crashed. This file is +often referred to as a @dfn{core dump}.@footnote{The terminology dates +back to the time of magnetic core memory.} Combined with information from the +symbol table produced by @option{-g}, the core dump can be used to find +the line where the program stopped, and the values of its variables at +that point. @cindex deployment, options for -This is useful both during the development of software, and after +This is useful both during the development of software and after deployment---it allows problems to be investigated when a program has crashed ``in the field''. @@ -2444,16 +2592,17 @@ @end example @noindent @cindex dereferencing, null pointer -@cindex null pointer, attempt to dereference +@cindex null pointer @cindex bug, example of The program attempts to dereference a null pointer @code{p}, which is an invalid operation. On most systems, this will cause a -crash. @footnote{Historically, a null pointer has typically corresponded -to memory location 0, which is usually restricted to the operating -system kernel and not accessible to user programs.} +crash. @footnote{Historically, a null pointer corresponded to memory +location 0, which is typically restricted to the operating system +kernel. In practice this is not always how a null pointer works, but +the result is usually the same.} -In order to be able to find the cause of the crash later, we need to -compile the program with the @option{-g} option: +In order to be able to find the cause of the crash later, we will need +to compile the program with the @option{-g} option: @example $ gcc -Wall -g null.c @@ -2464,7 +2613,7 @@ Running the executable file on an x86 GNU/Linux system will cause the operating system to terminate the program abnormally: -@cindex segmentation fault, error message +@cindex segmentation fault @example $ ./a.out @@ -2483,7 +2632,7 @@ memory which had been allocated to it. @cindex core file, not produced -@cindex @code{ulimit} command +@cindex @command{ulimit} command Some systems are configured not to write core files by default, since the files can be large and rapidly fill up the available disk space on a system. In the @cite{GNU Bash} shell the command @code{ulimit -c} @@ -2512,9 +2661,9 @@ Note that this setting only applies to the current shell. To set the limit for future sessions the command should be placed in an appropriate login file, such as @file{.bash_profile} for the GNU Bash shell. -@cindex @code{bash} profile file, login settings +@cindex @code{bash} profile file -@cindex core file, debugging with @code{gdb} +@cindex core file, examining @cindex @code{gdb}, debugging core file with Core files can be loaded into the GNU Debugger @code{gdb} with the following command: @@ -2543,7 +2692,7 @@ Loaded symbols for /lib/libc.so.6 Reading symbols from /lib/ld-linux.so.2...done. Loaded symbols for /lib/ld-linux.so.2 -#0 0x080483ed in a (p=0x0) at null.c:13 +#0 0x080483ed in foo (p=0x0) at null.c:13 13 int y = *p; (gdb) @end example @@ -2577,15 +2726,159 @@ @example (gdb) backtrace -#0 0x080483ed in a (p=0x0) at null.c:13 +#0 0x080483ed in foo (p=0x0) at null.c:13 #1 0x080483d9 in main () at null.c:7 @end example @noindent -In this case, the backtrace shows that the crash at line 13 occurred when -the function @code{a()} was called with an argument of @code{p=0x0}, from -line 7 in @code{main()}. It is possible to move to different levels in -the stack trace, and examine their variables, using the debugger -commands @code{up} and @code{down}. +In this case, the backtrace shows that the crash occurred at line 13 +after the function @code{foo} was called from @code{main} with an argument of +@code{p=0x0} at line 7 in @file{null.c}. It is possible to move to +different levels in the stack trace, and examine their variables, using +the debugger commands @code{up} and @code{down}. + +@node Setting a breakpoint +@section Setting a breakpoint +@cindex @code{break}, command in @code{gdb} +@cindex breakpoints, defined +@cindex stopping execution, with breakpoints in @code{gdb} + +A @dfn{breakpoint} stops the execution of a program and returns control +to the debugger, where its variables and memory can be examined before +continuing. Breakpoints can be set for specific functions, lines or +memory locations with the @code{break} command. + +To set a breakpoint on a specific function, use the command @code{break +@var{function-name}}. For example, the following command sets a +breakpoint at the start of the @code{main} function in the program +above: + +@example +$ gdb a.out +(gdb) break main +Breakpoint 1 at 0x80483c6: file null.c, line 6. +@end example +@noindent +The debugger will now take control of the program when the function +@code{main} is called. Since the @code{main} function is the first +function to be executed in a C program the program will stop immediately +when it is run: + +@example +(gdb) run +Starting program: a.out +Breakpoint 1, main () at null.c:6 +6 int *p = 0; /* null pointer */ +(gdb) +@end example +@noindent +The display shows the line that will be executed next (the line number +is shown on the left). The breakpoint stops the program @emph{before} +the line is executed, so at this stage the pointer @code{p} is +undefined and has not yet been set to zero. + +@node Stepping through the program +@section Stepping through the program +@cindex @code{step}, command in @code{gdb} +@cindex @code{next}, command in @code{gdb} + +To move forward and execute the line displayed above, use the command +@code{step}: + +@example +(gdb) step +7 return foo (p); +@end example +@noindent +After executing line 6, the debugger displays the next line to be +executed. The pointer @code{p} will now have been set to zero (null): + +@example +(gdb) print p +$1 = (int *) 0x0 +@end example +@noindent +The command @code{step} will follow the execution of the program +interactively through any functions that are called in the current +line. If you want to move forward without tracing these calls, +use the command @code{next} instead. + +@node Modifying variables +@section Modifying variables +@cindex @code{set}, command in @code{gdb} + +To temporarily fix the null pointer bug discovered above, we can change +the value of @code{p} in the running program using the @code{set +variable} command. + +Variables can be set to a specific value, or to the result of an +expression, which may include function calls. This powerful feature +allows functions in a program to be tested interactively through the +debugger. + +In this case we will interactively allocate some memory for the pointer +@code{p} using the function @code{malloc}, storing the value 255 in the +resulting location: + +@example +(gdb) set variable p = malloc(sizeof(int)) +(gdb) print p +$2 = (int *) 0x40013f98 @r{(address allocated by @code{malloc})} +(gdb) set variable *p = 255 +(gdb) print *p +$3 = 255 +@end example +@noindent +If we now continue stepping through the program with the new value of +@code{p} the previous segmentation fault will not occur: + +@example +(gdb) step +foo (p=0x40013f98) at null.c:13 +13 int y = *p; +(gdb) step +14 return y; +@end example + +@node Continuing execution +@section Continuing execution +@cindex @code{finish}, command in @code{gdb} +@cindex @code{continue}, command in @code{gdb} +The command @code{finish} continues execution up to the end of the +current function, displaying the return value: + +@example +(gdb) finish +Run till exit from #0 0x08048400 in foo (p=0x40013f98) +at null.c:15 +0x080483d9 in main () at null.c:7 +7 return foo (p); +Value returned is $13 = 255 +@end example +@noindent +@cindex exit code, displayed in @code{gdb} +To continue execution until the program exits (or hits the next +breakpoint) use the command @code{continue}, + +@example +(gdb) continue +Continuing. +Program exited with code 0377. +@end example +@noindent +Note that the exit code is shown in octal (0377 base 8 = 255 in base 10). + +@node More information about GDB +@section More information +@cindex Emacs, @code{gdb} mode +@cindex @code{gdb}, Emacs mode +@cindex @code{gdb}, graphical interface +@cindex Insight, graphical interface for @code{gdb} +For simplicity, the examples in this chapter demonstrate how to use +@code{gdb} on the command-line. There are more powerful ways to debug a +program interactively using tools such as Emacs @sc{gdb} mode (@kbd{M-x +gdb}), @sc{ddd} or @sc{insight}, graphical interfaces to @code{gdb}. +Links to these programs can be found on the publisher's webpage for this +book.@footnote{@uref{http://www.network-theory.co.uk/gcc/intro/}} A complete description of all the commands available in @code{gdb} can be found in the manual ``@cite{Debugging with GDB: The GNU Source-Level @@ -2750,7 +3043,7 @@ be used to request explicitly that a specific function should be inlined wherever possible, including its use in other files.@footnote{In this case, the definition of the inline function must be made available to -the other files (in a header file, for example).} The GCC Reference +the other files (e.g. in a header file).} The GCC Reference Manual ``@cite{Using GCC}'' provides full details of the @code{inline} keyword, and its use with the @code{static} and @code{extern} qualifiers to control the linkage of explicitly inlined functions (@pxref{Further @@ -2767,8 +3060,8 @@ program simultaneously, other types of optimization produce faster code at the expense of increasing the size of the executable. This choice between speed and memory is referred to as a @dfn{speed-space tradeoff}. -Optimizations with a speed-space tradeoff can also be used to make an -executable smaller, at the expense of making it run slower. +Optimizations with a speed-space tradeoff can also be used in reverse +to make an executable smaller, at the expense of making it run slower. @subsection Loop unrolling @cindex loop unrolling, optimization @@ -2890,10 +3183,8 @@ compiles the source code in the most straightforward way possible. Each command in the source code is converted directly to the corresponding instructions in the executable file, without rearrangement. This is the -best option to use when debugging a program. - -The option @option{-O0} is equivalent to not specifying a @option{-O} -option. +best option to use when debugging a program and is the default +if no optimization level option is specified. @item @option{-O1} @r{or} @option{-O} @cindex @option{-O1} option, optimization level one @@ -2962,7 +3253,7 @@ @node Optimization examples @section Examples @cindex optimization, example of -@cindex examples, of optimization + The following program will be used to demonstrate the effects of different optimization levels: @@ -3081,14 +3372,14 @@ The @option{-Wuninitialized} option (which is included in @option{-Wall}) warns about variables that are read without being initialized. It only works when the program is compiled with -optimization to enable data-flow analysis. The following function +optimization, so that data-flow analysis is enabled. The following function contains an example of such a variable: @example @verbatiminclude uninit.c @end example @noindent -@cindex C/C++, risks of using, example +@cindex C/C++, risks of using The function works correctly for most arguments, but has a bug when @code{x} is zero---in this case the return value of the variable @code{s} will be undefined. @@ -3141,6 +3432,7 @@ @menu * Compiling a simple C++ program:: +* C++ compilation options:: * Using the C++ standard library:: * Templates:: @end menu @@ -3151,7 +3443,7 @@ @cindex C++, compiling a simple program with @code{g++} @cindex @code{g++}, compiling C++ programs @cindex compiling C++ programs with @code{g++} -@cindex simple C++ program, compiling with @code{g++} +@cindex simple C++ program, compiling The procedure for compiling a C++ program is the same as for a C program, but uses the command @code{g++} instead of @code{gcc}. Both @@ -3220,7 +3512,7 @@ @code{g++}, in order to supply the appropriate C++ libraries. Attempting to link a C++ object file with the C compiler @code{gcc} will cause ``undefined reference'' errors for C++ standard library functions: -@cindex @code{undefined reference} to C++ function, due to linking with @code{gcc} +@cindex undefined reference to C++ function, due to linking with @code{gcc} @example $ g++ -Wall -c hello.cc @@ -3232,8 +3524,11 @@ undefined reference to `__gxx_personality_v0' @end example @noindent -Linking the same object file with @code{g++} supplies all the necessary -C++ libraries and will produce a working executable: +Undefined references to internal run-time library functions, such as +@code{__gxx_personality_v0}, are also a symptom of linking C++ object +files with @code{gcc} instead of @code{g++}. Linking the same object +file with @code{g++} supplies all the necessary C++ libraries and will +produce a working executable: @example $ g++ hello.o @@ -3244,7 +3539,7 @@ @cindex @code{__gxx_personality_v0}, undefined reference error @cindex @code{gxx_personality_v0}, undefined reference error @cindex @code{gcc}, used inconsistently with @code{g++} -@cindex undefined reference error, @code{__gxx_personality_v0} +@cindex undefined reference error for @code{__gxx_personality_v0} A point that sometimes causes confusion is that @code{gcc} will actually compile C++ source code when it detects a C++ file extension, but cannot then link the resulting object files. @@ -3256,8 +3551,59 @@ hello.o(.text+0x1b): undefined reference to `std::cout' @end example @noindent -In order to avoid this problem it is best to use @code{g++} consistently -for C++ programs, and @code{gcc} for C programs. +To avoid this problem, use @code{g++} consistently for C++ +programs and @code{gcc} for C programs. + +@node C++ compilation options +@section C++ compilation options + +Most GCC options can be used for both C and C++ programs, but there are +also a few options which are specific to each language. This section +describes some of the additional options, and enhancements to existing +options, that are available in @command{g++}. + +@table @asis +@item @option{-Wall} and @option{-W} +When compiling with @code{g++}, the options @option{-Wall} and +@option{-W} include extra warnings specific to C++ (the warnings relate +to member functions and virtual classes). The use of these options is +always recommended while developing a program. + +@item @option{-fno-default-inline} +@cindex @option{-fno-default-inline} option +@cindex @option{fno-default-inline} option +@cindex @option{no-default-inline} option +This option disables the default inlining of member functions defined in +the bodies of C++ classes. GCC normally inlines all such +functions when optimization is turned on, even if they do not explicitly +use the @code{inline} keyword. Select this option if you prefer to +control inlining yourself, or want to set a breakpoint on member +functions that would otherwise be inlined (since it is not possible to +set a breakpoint on an inlined function). + +@item @option{-Weffc++} +@cindex @option{-Weffc++} option +@cindex @option{Weffc++} option +@cindex @option{effc++} warning option +This option warns about C++ code which breaks some of the programming +guidelines given in the books ``@cite{Effective C++}'' and ``@cite{More +Effective C++}'' by Scott Meyers. For example, a warning will be given +if a class which uses dynamically allocated memory does not define a +copy constructor and an assignment operator. Note that the standard +library header files do not follow these guidelines, so you may wish to +use this option as an occasional test for possible problems in your own +code rather than compiling with it all the time. + +@item @option{-Wold-style-cast} +@cindex @option{-Wold-style-cast} option +@cindex @option{Wold-style-cast} option +@cindex @option{old-style-cast} warning option + +This option highlights any uses of C-style casts in C++ programs. The +C++ language provides the keywords @code{static_cast}, @code{dynamic_cast}, +@code{reinterpret_cast} and @code{const_cast} for handling casts +and these are often preferable (although C-style casts are still allowed). +@end table @node Using the C++ standard library @section Using the C++ standard library @@ -3282,7 +3628,7 @@ @end example @noindent @cindex C++, namespace @code{std} -@cindex Namespace @code{std} in C++ +@cindex namespace @code{std} in C++ @cindex @code{std} namespace in C++ @cindex header file, without @code{.h} extension for C++ Note that in accordance with the C++ standard, the header files for the @@ -3313,7 +3659,6 @@ @node Using C++ standard library templates @subsection Using C++ standard library templates -@cindex templates, in C++ standard library @cindex Standard Template Library (STL) @cindex C++, standard library templates The C++ standard library @file{libstdc++} supplied with GCC provides a @@ -3340,7 +3685,7 @@ List size = 2 @end example @noindent -@cindex C++, standard library @code{libstdc++} +@cindex C++, standard library @cindex @code{libstdc++}, C++ standard library Note that the executables created by @code{g++} using the C++ standard library will be linked to the shared library @file{libstdc++}, which is @@ -3383,7 +3728,7 @@ purposes and should not be considered an example of good programming. Note the use of @dfn{include guards}, which test for the presence of the macro @w{@code{BUFFER_H}}, ensuring that the definitions in the header -file are only parsed once, if the file is included multiple times in the +file are only parsed once if the file is included multiple times in the same context. The program below uses the templated @code{Buffer} class to create a @@ -3409,7 +3754,7 @@ @code{g++} compiles the appropriate definition from the header file and places the compiled function in the corresponding object file. -@cindex @code{multiply defined symbol} error, with C++ +@cindex multiply-defined symbol error, with C++ @cindex linker, GNU compared with other linkers If a template function is used several times in a program it will be stored in more than one object file. The GNU Linker ensures that only @@ -3425,14 +3770,14 @@ @cindex instantiation, explicit vs implicit in C++ @cindex explicit instantiation of templates @cindex @option{-fno-implicit-templates} option, disable implicit instantiation -@cindex @code{fno-implicit-templates} option, disable implicit instantiation +@cindex @option{fno-implicit-templates} option, disable implicit instantiation To achieve complete control over the compilation of templates with @code{g++} it is possible to require explicit instantiation of each occurrence of a template, using the option -@option{-fno-implicit-templates}. This method is not needed when using -the GNU Linker---it is an alternative to the inclusion compilation -model for systems with linkers which cannot eliminate duplicate -definitions of template functions in object files. +@option{-fno-implicit-templates}. This method is not needed when +using the GNU Linker---it is an alternative provided for systems with +linkers which cannot eliminate duplicate definitions of template +functions in object files. In this approach, template functions are no longer compiled at the point where they are used, as a result of the @option{-fno-implicit-templates} @@ -3501,7 +3846,7 @@ @cindex templates, @code{export} keyword At the time of writing, GCC does not support the new C++ @code{export} -keyword (GCC 3.3.2). +keyword (GCC 3.4.4). This keyword was proposed as a way of separating the interface of templates from their implementation. However it adds its own complexity @@ -3542,6 +3887,8 @@ * SPARC options:: * POWER/PowerPC options:: * Multi-architecture support:: +* Floating-point issues:: +* Portability of signed and unsigned types:: @end menu @node Intel and AMD x86 options @@ -3586,17 +3933,64 @@ plan to distribute executable files for general use on Intel and AMD processors they should be compiled without any @option{-march} options. +@cindex @option{-mtune} option +@cindex @option{mtune} option +@cindex @option{tune} machine-specific option + As an alternative, the @option{-mcpu=@var{CPU}} option provides a compromise between speed and portability---it generates code that is tuned for a specific processor, in terms of instruction scheduling, but does not use any instructions which are not available on other CPUs in -the x86 family. The resulting code will be compatible with all the -CPUs, and have a speed advantage on the CPU specified by @option{-mcpu}. -The executables generated by @option{-mcpu} cannot achieve the same +the x86 family.@footnote{In recent versions of GCC this option has been +renamed to @option{-mtune}. The older form @option{-mcpu} will continue +to work.} The resulting code will be compatible with all the CPUs, and +have a speed advantage on the CPU specified by @option{-mcpu}. The +executables generated by @option{-mcpu} cannot achieve the same performance as @option{-march}, but may be more convenient in practice. -@cindex 64-bit processor specific options, AMD64 and Intel +@menu +* x86 extensions:: +* x86 64-bit processors :: +@end menu + +@node x86 extensions +@subsection x86 extensions +@cindex SSE extensions +@cindex MMX extensions +@cindex illegal instruction error +@cindex @option{-msse} and related options +@cindex @option{msse} and related options + +GCC can take advantage of the additional instructions in the MMX, SSE, +SSE2, SSE3 and 3dnow extensions of recent Intel and AMD processors. The +options @option{-mmmx}, @option{-msse}, @option{-msse2}, @option{-msse3} +and @option{-m3dnow} enable the use of these extra instructions, allowing +multiple words of data to be processed in parallel. The resulting +executables will only run on processors supporting the appropriate +extensions---on other systems they will crash with an @code{Illegal +instruction} error (or similar).@footnote{On GNU/Linux systems, the command @code{cat /proc/cpuinfo} will display information about the CPU.} + +@cindex floating point arithmetic, with SSE extensions +@cindex @option{-mfpmath} option, for floating-point arithmetic +@cindex @option{mfpmath} option, for floating-point arithmetic +@cindex @option{fpmath} option, for floating-point arithmetic +The option @option{-mfpmath=sse} instructs GCC to use the SSE extensions +for floating-point arithmetic where possible. For this option to take +effect, the SSE or SSE2 extensions must first be enabled with +@option{-msse} or @option{-msse2}. + +Note that the plain SSE extensions only support single precision +operations---double precision arithmetic is part of SSE2. Since most C +and C++ programs declare floating-point variables as @code{double} +rather than @code{float}, the combined options @code{-msse2 +-mfpmath=sse} are usually needed. On 64-bit processors these +options are enabled by default. + +@node x86 64-bit processors +@subsection x86 64-bit processors +@cindex 64-bit processor-specific options, AMD64 and Intel @cindex AMD64, 64-bit processor specific options + AMD has enhanced the 32-bit x86 instruction set to a 64-bit instruction set called x86-64, which is implemented in their AMD64 processors.@footnote{Intel has added support for this instruction set as @@ -3644,7 +4038,7 @@ @cindex underflow, on DEC Alpha @cindex gradual underflow, on DEC Alpha @cindex soft underflow, on DEC Alpha -@cindex zero, rounding to by underflow, on DEC Alpha +@cindex zero, from underflow on DEC Alpha Support for infinity arithmetic and gradual underflow (denormalized numbers) is not enabled in the default configuration on the DEC Alpha processor. Operations which produce infinities or underflows will @@ -3678,7 +4072,7 @@ Floating point exception @r{(on an Alpha processor)} @end example @noindent -@cindex @code{Floating point exception}, on DEC Alpha +@cindex floating point exception, on DEC Alpha Using the @option{-mieee} option ensures full IEEE compliance -- the division 1/0 correctly produces the result @code{inf} and the program continues executing successfully: @@ -3810,6 +4204,299 @@ knows about these paths and uses the appropriate path when compiling 64-bit or 32-bit code. +@node Floating-point issues +@section Floating-point issues +@cindex floating point, portability problems +@cindex arithmetic, floating-point +@cindex numerical differences +@macro scinum{a,b} +@iftex +@tex +$\a\ \\times 10^{ \b\ }$@comment +@end tex +@end iftex +@ifnottex +\a\*10^\b\@comment +@end ifnottex +@end macro + +@macro sciexp{a,b} +@iftex +@tex +$\a\^{ \b\ }$@comment +@end tex +@end iftex +@ifnottex +\a\^\b\@comment +@end ifnottex +@end macro + +@macro scirange{a,b} +@iftex +@tex +$\a\^{\\pm \b\ }$@comment +@end tex +@end iftex +@ifnottex +\a\^(+/-\b\)@comment +@end ifnottex +@end macro +@cindex IEEE arithmetic + +The IEEE-754 standard defines the bit-level behavior of floating-point +arithmetic operations on all modern processors. This allows numerical +programs to be ported between different platforms with identical +results, in principle. In practice, there are often minor variations +caused by differences in the order of operations (depending on the +compiler and optimization level) but these are generally not +significant. + +@cindex x86, floating-point arithmetic +@cindex Motorola 680x0, floating-point arithmetic +@cindex native double-precision processors +@cindex double precision +@cindex extended precision, x86 processors +However, more noticeable discrepancies can be seen when porting +numerical programs between x86 systems and other platforms, because the +the x87 floating point unit (FPU) on x86 processors computes results +using extended precision internally (the values being converted to +double precision only when they are stored to memory). In contrast, +processors such as SPARC, PA-RISC, Alpha, MIPS and POWER/PowerPC work +with native double-precision values throughout.@footnote{Motorola 68k +processors also use extended precision registers, like the x86.} The +differences between these implementations lead to changes in rounding +and underflow/overflow behavior, because intermediate values have a +greater relative precision and exponent range when computed in extended +precision.@footnote{For quantities held in the x87 extended-precision +registers the relative precision is @scinum{5.42,-20} and the exponent +range is @scirange{10,4932}. Standard double precision values have a +relative precision of @scinum{2.22,-16} and an exponent range of +@scirange{10,308}.} In particular, comparisons involving extended +precision values may fail where the equivalent double precision values +would compare equal. +@cindex rounding, floating-point arithmetic +@cindex overflow, floating-point arithmetic +@cindex underflow, floating-point arithmetic + +To avoid these incompatibilities, the x87 FPU also offers a hardware +double-precision rounding mode. In this mode the results of each +extended-precision floating-point operation are rounded to +double precision in the floating-point registers by the FPU. +It is important to note that the rounding +only affects the precision, not the exponent range, so the result is a +hybrid double-precision format with an extended range of exponents. + +@cindex FreeBSD, floating-point arithmetic +@cindex NetBSD, floating-point arithmetic +@cindex OpenBSD, floating-point arithmetic +@cindex GNU/Linux, floating-point arithmetic +@cindex Linux kernel, floating-point +@cindex @code{fldcw} set floating point mode +@cindex @code{asm} extension keyword +@cindex machine instruction, @code{asm} keyword +On BSD systems such as FreeBSD, NetBSD and OpenBSD, the hardware +double-precision rounding mode is the default, giving the greatest +compatibility with native double precision platforms. On x86 GNU/Linux +systems the default mode is extended precision (with the aim of +providing increased accuracy). To enable the double-precision rounding +mode it is necessary to override the default setting on per-process +basis using the @sc{fldcw} ``floating-point load control-word'' machine +instruction.@footnote{The operating system saves and restores the +control word when switching between processes, so that each process +maintains its own setting.} A simple function which can be called to +execute this instruction is shown below. It uses the GCC extension +keyword @code{asm} to insert the specified instruction in the +assembly language output: + +@example +@verbatiminclude setfpu.c +@end example +@noindent +The appropriate @code{mode} setting for double-precision rounding is +@code{0x27F}. The mode value also controls the floating-point exception +handling behavior and rounding-direction (see the Intel and AMD +processor reference manuals for details). +@cindex floating point exception handling +@cindex exception handling, floating-point + +On x86 GNU/Linux, the function above can be called at the start of any +program to disable excess precision. This will then reproduce the +results of native double-precision processors, in the absence of +underflows and overflows. + +The following program demonstrates the different rounding modes: + +@example +@verbatiminclude fptest2.c +@end example +@noindent +On x86 GNU/Linux systems the comparison @code{c == a / b} can produce an +unexpected result if @code{c} is taken from memory (double precision) +while @code{a / b} is computed in extended precision, because the +fraction 3/7 has different representations in double and extended +precision. + +@example +$ gcc -Wall fptest.c +$ ./a.out +unexpected result +@end example +@noindent +Setting the hardware rounding mode to double precision prevents this +from happening: + +@example +$ gcc -Wall -DDOUBLE fptest.c +$ ./a.out +comparison succeeds +@end example +@noindent +Note that the floating-point control word affects the whole environment +of the process, including any C Library functions that are called. One +consequence of this is that @code{long double} arithmetic is effectively +reduced to double precision, since it relies on extended precision operations. +@cindex long double arithmetic + +@c @cindex @option{-ffloat-store} +@c The option @option{-ffloat-store} is sometimes suggested as a way to +@c avoid problems with excess precision---it forces floating-point values +@c to be stored in memory when they are assigned to a variable. However, +@c it does not affect intermediate expressions or conditionals, and can +@c slow down programs significantly. If necessary, it is possible to force +@c a single variable to remain in memory is by declaring it +@c @code{volatile}. + +@c @example +@c @verbatiminclude coerce.h +@c @end example +@c @noindent + +@c @example +@c @c @verbatiminclude fp.c +@c @end example +@c @noindent + +@cindex SSE/SSE2 precision +The floating point control word only affects the behavior of the x87 +FPU. Floating point operations computed with SSE and SSE2 instructions +are always carried out in native double precision. Thus, the combined +options + +@example +$ gcc -Wall -msse2 -mfpmath=sse ... +@end example +@noindent +are often sufficient to remove the effects of extended-precision. +However, some operations (such as transcendental functions) are not +available in the SSE/SSE2 extensions and will still be computed on the +x87 FPU. + +@node Portability of signed and unsigned types +@section Portability of signed and unsigned types +@cindex signed @code{char} option +@cindex unsigned @code{char} option +@cindex @code{char}, portability of signed vs unsigned + +The C and C++ standards allows the character type @code{char} to be +signed or unsigned, depending on the platform and compiler. Most +systems, including x86 GNU/Linux and Microsoft Windows, use signed +@code{char}, but those based on PowerPC and @sc{arm} processors +typically use unsigned @code{char}.@footnote{MacOS X (Darwin) on +PowerPC uses signed @code{char}, for consistency with other Darwin +architectures.} This can lead to unexpected results when porting +programs between platforms which have different defaults for the type +of @code{char}. + +The following code demonstrates the difference between platforms with +signed and unsigned @code{char} types: + +@example +@verbatiminclude signed.c +@end example +@noindent +With an unsigned @code{char}, the variable @code{c} takes the value 255, +but with a signed @code{char} it becomes @math{-1}. + +The correct way to manipulate @code{char} variables in C is through the +portable functions declared in @file{ctype.h}, such as @code{isalpha}, +@code{isdigit} and @code{isblank}, rather than by their numerical +values. The behavior of non-portable conditional expressions such as +@code{c > 'a'} depends on the signedness of the @code{char} type. If +the signed or unsigned version of @code{char} is explicitly required at +certain points in a program, it can be specified using the declarations +@code{signed char} or @code{unsigned char}. + +For existing programs which assume that @code{char} is signed or +unsigned, GCC provides the options @option{-fsigned-char} and +@option{-funsigned-char} to set the default type of @code{char}. Using +these options, the example code above compiles cleanly when @code{char} +is unsigned: +@cindex @option{-funsigned-char} option +@cindex @option{-fsigned-char} option + +@example +$ gcc -Wall -funsigned-char signed.c +$ ./a.out +char is unsigned (c = 255) +@end example +@noindent +However, when @code{char} is signed the value 255 wraps around to +@math{-1}, giving a warning: + +@example +$ gcc -Wall -fsigned-char signed.c +signed.c: In function `main': +signed.c:7: warning: comparison is always false due to + limited range of data type +$ ./a.out +char is signed (c = -1) +@end example +@noindent +The warning message @cite{``comparison is always true/false due to +limited range of data type''} is one symptom of code which assumes a +definition of @code{char} which is different from the actual type. + +The most common problem with code written assuming signed @code{char} +types occurs with the functions @code{getc}, @code{fgetc} and +@code{getchar} (which read a character from a file). They have a return +type of @code{int}, not @code{char}, and this allows them to use the +special value @math{-1} (defined as @code{EOF}) to indicate an +end-of-file error. Unfortunately, many programs have been written which +incorrectly store this return value straight into a @code{char} +variable. Here is a typical example: + +@example +@verbatiminclude testgetc.c +@end example +@noindent +This only works on platforms which default to a signed @code{char} +type.@footnote{There is also a subtle error even on +platforms with signed @code{char}---the @sc{ascii} character 255 +is spuriously interpreted as an end of file condition.} +On platforms which use an unsigned @code{char} the same code will fail, +because the value @math{-1} becomes 255 when stored in an @code{unsigned +char}. This usually causes an infinite loop because the end of the file +cannot be recognized.@footnote{If displayed, character code 255 often appears as @code{@"y}.} +To be portable, the program should test the +return value as an integer before coercing it to a @code{char}, as +follows: + +@example +@verbatiminclude testgetc2.c +@end example +@noindent + +@cindex signed bitfield option +@cindex unsigned bitfield option +@cindex bitfields, portability of signed vs unsigned +@cindex @option{-funsigned-bitfields} option +@cindex @option{-fsigned-bitfields} option +The same considerations described in this section apply to the +definitions of bitfields in structs, which can be signed or unsigned by +default. In GCC, the default type of bitfields can be controlled using +the options @option{-fsigned-bitfields} and @option{-funsigned-bitfields}. + + @node Troubleshooting @chapter Troubleshooting @cindex troubleshooting options @@ -3824,13 +4511,14 @@ * Help for command-line options:: * Version numbers:: * Verbose compilation:: +* Stopping a program in an infinite loop:: +* Preventing excessive memory usage:: @end menu @node Help for command-line options @section Help for command-line options @cindex @option{--help} option, display command-line options -@cindex @option{help} option, display command-line options To obtain a brief reminder of various command-line options, GCC provides a help option which displays a summary of the top-level GCC command-line options: @@ -3865,7 +4553,6 @@ option: @cindex version number of GCC, displaying @cindex @option{--version} option, display version number -@cindex @option{version} option, display version number @example $ gcc --version @@ -3951,6 +4638,148 @@ and the object files and libraries used for linking. +@node Stopping a program in an infinite loop +@section Stopping a program in an infinite loop +@cindex infinite loop, stopping +@cindex control-C, interrupt +@cindex SIGINT signal +@cindex @code{attach}, debug running program + +A program which goes into an infinite loop or ``hangs'' can be difficult +to debug. On most systems a foreground process can be stopped by +hitting @kbd{Control-C}, which sends it an interrupt signal (@sc{sigint}). +However, this does not help in debugging the problem---the @sc{sigint} +signal terminates the process without producing a core dump. A more +sophisticated approach is to @dfn{attach} to the running process with +a debugger and inspect it interactively. + +For example, here is a simple program with an infinite loop: + +@example +@verbatiminclude loop.c +@end example +@noindent +In order to attach to the program and debug it, the code should be +compiled with the debugging option @option{-g}: + +@example +$ gcc -Wall -g loop.c +$ ./a.out +@r{(program hangs)} +@end example +@noindent +@cindex process id, finding +Once the executable is running we need to find its process id +(@sc{pid}). This can be done from another session with the command +@code{ps x}: + +@example +$ ps x +PID TTY STAT TIME COMMAND +... ..... . .... +891 pts/1 R 0:11 ./a.out +@end example +@noindent +In this case the process id is 891, and we can now attach to it with +@code{gdb}. The debugger should be started in the directory containing +the executable and its source code:@footnote{Alternatively, the +appropriate paths can be set up in @code{gdb} using the @code{file} and +@code{directory} commands.} + +@example +$ gdb a.out +(gdb) attach 891 +Attaching to program: a.out, process 891 +Reading symbols from /lib/libc.so.6...done. +Loaded symbols for /lib/libc.so.6 +Reading symbols from /lib/ld-linux.so.2...done. +Loaded symbols for /lib/ld-linux.so.2 +0x080483d4 in main () at loop.c:5 +5 while (1) @{ i++; @}; +(gdb) +@end example +@noindent +The output shows the line that was about to execute at the point when +the debugger attached to the process. The attached program is paused but +still ``live''---it can be examined interactively and continued or +terminated (with the @code{kill} command) if necessary: + +@example +(gdb) print i +$1 = 1213315528 +(gdb) kill +Kill the program being debugged? (y or n) y +(gdb) +@end example +@noindent +@cindex SIGQUIT signal +If you want to stop a process immediately and create a core dump, the +shell command @code{kill -3 @var{pid}} (where @var{pid} is the process +id) will send it a @sc{sigquit} signal. The @sc{sigquit} signal does +trigger a core dump, unlike @sc{sigint}. Note that if core dumps were +disabled when the process was started, no core file will be produced +(@pxref{Examining core files}). + +@node Preventing excessive memory usage +@section Preventing excessive memory usage +@cindex memory usage, limiting +@cindex virtual memory usage, limiting +@cindex @command{ulimit} command + +Sometimes a programming error will cause a process to allocate huge +amounts of memory, consuming all the @sc{ram} on a system. To prevent +this, the GNU Bash command @command{ulimit -v @var{limit}} can be used +to restrict the amount of virtual memory available to each process. The +limit is measured in kilobytes and applies to new processes started in +the current shell. For example, + +@example +$ ulimit -v 4096 +@end example +@noindent +will limit subsequent processes to 4 megabytes of virtual memory +(4096k). By default the limit cannot be increased in the same session +once it has been applied, so it is best to start a separate shell for +reduced @code{ulimit} operations. Alternatively, you can set a +@dfn{soft limit} (which can be undone) with the options @option{-S -v}. + +In addition to preventing run-away processes, limiting the amount of +memory a program is allowed to allocate also provides a way to test how +robustly @dfn{out of memory} conditions are handled. An artificially low +limit can be used to simulate running out of memory---a well-written +program should not crash in this case. + +@c The following program tries to allocate 32 megabytes of memory using +@c @code{malloc}: + +@c @example +@c @verbatiminclude outofmem.c +@c @end example +@c @noindent +@c Under normal circumstances, the program executes without problems: + +@c @example +@c $ gcc -Wall outofmem.c +@c $ ./a.out +@c Allocating 32 megabytes... success +@c @end example + +@c If we restrict the available virtual memory to 4 megabytes, the call to +@c @code{malloc} will fail: + +@c @example +@c $ ulimit -v 4096 +@c $ ./a.out +@c Allocating 32 megabytes... FAILED +@c @end example + +The @command{ulimit} command supports other options including +@option{-p}, which restricts the number of child processes that can be +created, and @option{-t}, which places a limit on the number of @sc{cpu} +seconds that a process can run for. The complete list of settings can be +shown with the command @code{ulimit -a}. To display more information +about the @code{ulimit} command, type @code{help ulimit} at the Bash prompt. + @node Compiler-related tools @chapter Compiler-related tools @cindex compiler-related tools @@ -4510,7 +5339,7 @@ @item LSB @cindex LSB, least significant byte @cindex MSB, most significant byte -@cindex Motorola 680x0 +@cindex Motorola 680x0, word-order @cindex word-ordering, endianness @cindex endianness, word-ordering @cindex big-endian, word-ordering @@ -4583,6 +5412,7 @@ @node Finding dynamically linked libraries @section Finding dynamically linked libraries @cindex dynamically linked libraries, examining with @code{ldd} +@cindex shared libraries, examining with @code{ldd} @cindex @code{ldd}, dynamical loader @cindex dependencies, of shared libraries @cindex shared libraries, dependencies @@ -4628,16 +5458,709 @@ themselves, in order to follow a chain of shared library dependencies. +@node Common error messages +@chapter Common error messages +@cindex error messages, common examples +@cindex common error messages + +This chapter describes the most frequent error and warning messages +produced by @code{gcc} and @code{g++}. Each case is accompanied by a +description of the causes, an example and suggestions of possible +solutions. + +@menu +* Preprocessor error messages:: +* Compiler error messages:: +* Linker error messages:: +* Runtime error messages:: +@end menu + + +@node Preprocessor error messages +@section Preprocessor error messages +@cindex preprocessor, error messages + +@table @code +@item No such file or directory +@cindex No such file or directory + +This error occurs if GCC cannot find a requested file on its search +path. The file may have been specified on the command-line, or with a +preprocessor @code{#include} statement. Either the filename has been +spelled incorrectly or the directory for the file needs to be added to the +include path or link path. + +Example: + +@example +@verbatiminclude msg-file.c +@end example +@noindent +The program above tries to include the non-existent file @file{stdoi.h} +giving the error @samp{stdoi.h: No such file or directory}. The correct +filename should be @file{stdio.h}. + +@item macro or '#include' recursion too deep +@itemx #include nested too deeply +@cindex macro or '#include' recursion too deep +@cindex include nested too deeply + +This error occurs if the preprocessor encounters too many nested +@samp{#include} directives. It is usually caused by two or more files +trying to include each other, leading to an infinite recursion. + +Example: + +@example +@verbatiminclude msg-nest1.h +@end example + +@example +@verbatiminclude msg-nest2.h +@end example +@noindent +The solution to this problem is to ensure that files do not mutually +include each other, or to use ``include guards'' (@pxref{Providing your +own templates} for an example). + +@item invalid preprocessing directive #... +@cindex invalid preprocessing directive + +This error indicates that the preprocessor encountered an unrecognized +@code{#} command. + +Example: + +@example +@verbatiminclude msg-invalidpp.c +@end example +@noindent +The preprocessor syntax requires @code{#elif} for the ``else if'' condition in +@code{#if} blocks, rather than @code{#elseif}. In the example above +an invalid directive error occurs at the incorrect usage +@code{#elseif}, but only when @code{FOO} is defined (otherwise the +preprocessor ignores everything up to the @code{#else} statement). +@cindex @code{#elif}, preprocessor directive +@cindex @code{#else}, preprocessor directive + +@item warning: This file includes at least one deprecated or antiquated header. +@cindex file includes at least one deprecated or antiquated header +@cindex deprecated header in C++ +@cindex antiquated header in C++ +@cindex old-style C++ header files + +This warning is generated for C++ programs which include old-style +library header files, such as @file{iostream.h}, instead of the modern +C++ library headers without the @file{.h} extension. The old headers +import their functions into the top-level global namespace, instead of +using the @code{std::} namespace. Note that old-style header files are +still supported, so this message is only a warning and existing programs +will continue to compile. The message is actually generated by a +@code{#warning} directive in the old header files, and not by the +preprocessor itself. +@cindex @code{#warning}, preprocessor directive + +Example: + +@example +@verbatiminclude msg-cppheader.c +@end example +@noindent +This program uses an old-style header file @file{iostream.h}. It could +be updated to use @code{#include } and @code{std::cout} +instead. +@end table + +@node Compiler error messages +@section Compiler error messages +@cindex compiler, error messages + +@table @code +@item `@var{variable}' undeclared (first use in this function) +@cindex undeclared variable + +In C and C++ variables must be declared before they can be used. This +error message indicates that the compiler has encountered a variable +name which does not have a corresponding declaration. It can be caused +by a missing declaration, or a typing error in the name. Variable names +are case-sensitive, so @code{foo} and @code{Foo} represent different +variables. To keep the output short, only the first use of an +undeclared variable is reported. + +Example: + +@example +@verbatiminclude msg-undeclared.c +@end example +@noindent +The variable @code{j} is not declared and will trigger the error @code{`j' +undeclared}. + +@item parse error before `...' +@itemx syntax error +@cindex parse error +@cindex syntax error + +These error messages occur when the compiler encounters unexpected +input, i.e. sequences of characters which do not follow the syntax of +the language. The error messages can be triggered by a missing close +bracket, brace or semicolon preceding the line of the error, or an +invalid keyword. + +Example: + +@example +@verbatiminclude msg-parse.c +@end example +@noindent +There is a missing semicolon after the first call to @code{printf}, +giving a @code{parse error}. + +@item parse error at end of input +@cindex parse error at end of input + +This error occurs if the compiler encounters the end of a file +unexpectedly, such as when it has parsed an unbalanced number of opening +and closing braces. It is often caused by a missing closing brace +somewhere. + +Example: + +@example +@verbatiminclude msg-eoi.c +@end example +@noindent +An additional closing brace is needed in this program to prevent the +error @code{parse error at end of input}. + +@item warning: implicit declaration of function `...' +@cindex implicit declaration of function + +This warning is generated when a function is used without a prototype +being declared. It can be caused by failing to include a header file, +or otherwise forgetting to provide a function prototype. + +Example: + +@example +@verbatiminclude msg-implicitdecl.c +@end example +@noindent +The system header file @file{stdio.h} is not included, so the prototype +for @code{printf} is not declared. The program needs an initial line +@code{#include }. + +@item unterminated string or character constant +@cindex unterminated string or character constant + +This error is caused by an opening string or character quote which does +not have a corresponding closing quote. Quotes must occur in matching +pairs, either single quotes @code{'a'} for characters or double quotes +@code{"aaa"} for strings. + +Example: + +@example +@verbatiminclude msg-unterm.c +@end example +@noindent +The opening quote for the string in this program does not have a +corresponding closing quote, so the compiler will read the rest of the +file as part of the string. + +@item character constant too long +@cindex character constant too long + +In C and C++ character codes are written using single quotes, e.g. +@code{'a'} gives the ASCII code for the letter a (67), and @code{'\n'} +gives the ASCII code for newline (10). This error occurs if single quotes +are used to enclose more than one character. + +Example: + +@example +@verbatiminclude msg-string2.c +@end example +@noindent +The program above confuses single-quotes and double-quotes. A sequence +of characters should be written with double quotes, e.g. @code{"Hello +World!"}. This same problem occurs in the following C++ program, + +@example +@verbatiminclude msg-string2.cc +@end example +@noindent +This error can also occur if the forward slash and backslash are +confused in an escape sequence, e.g. using @code{'/n'} instead of +@code{'\n'}. The sequence @code{/n} consists of two separate +characters, @samp{/} and @samp{n}. + +Note that according to the C standard there is no limit on the length of +a character constant, but the value of a character constant that +contains more than one character is implementation-defined. Recent +versions of GCC provide support multi-byte character constants, and +instead of an error the warnings @code{multiple-character character +constant} or @code{warning: character constant too long for its type} +are generated in this case. +@cindex multiple-character character constant +@cindex character constant too long + +@item warning: initialization makes integer from pointer without a cast +@cindex initialization makes integer from pointer without a cast + +This error indicates a misuse of a pointer in an integer context. +Technically, it is possible to convert between integer and pointer +types, but this is rarely needed outside system-level applications. +More often, this warning is the result of using a pointer without +dereferencing it (e.g. writing @code{int i = p} instead of @code{int i += *p}). + +This warning can also occur with @code{char} and @code{char *} types, +since @code{char} is an integer type. + +Example: + +@example +@verbatiminclude msg-char.c +@end example +@noindent +The variable @code{c} has type @code{char}, while the string @code{"\n"} +evaluates to a @code{const char *} pointer (to a 2-byte region of memory +containing the ASCII value for newline followed by a zero byte @code{'\0'}, +since strings are null-terminated). The ASCII code for newline can be +found using @code{char c = '\n';} + +Similar errors can occur with misuse of the macro @code{NULL}, +@example +@verbatiminclude msg-null.c +@end example +@noindent +In C, the macro @code{NULL} is defined as @code{((void *)0)} in +@file{stdlib.h} and should only be used in a pointer context. + +@c Note that it is important to distinguish between the ASCII character +@c @sc{NUL} (character code 0) and the null pointer @code{NULL}. + +@c @example +@c int i = 0; @r{zero} +@c char c = '\0'; @r{null character, ASCII @sc{NUL}} +@c char * s = ""; @r{empty string, a pointer to '\0'} +@c void * p = NULL; @r{null pointer} +@c @end example + +@item dereferencing pointer to incomplete type +@cindex dereferencing pointer to incomplete type + +This error occurs when a program attempts to access the elements of +struct through a pointer without the layout of the struct being declared +first. In C and C++ it is possible to declare pointers to structs +before declaring their struct layout, provided the pointers are not +dereferenced---this is known as @dfn{forward declaration}. + +Example: + +@example +@verbatiminclude msg-derefincomplete.c +@end example +@noindent +This program has a forward declaration of the @code{btree} struct +@code{data}. However, the definition of the struct is needed before the +pointer can be dereferenced to access individual members. + +@item warning: unknown escape sequence `...' +@cindex unknown escape sequence + +This error is caused by an incorrect use of the escape character in a +string. Valid escape sequences are: + +@multitable @columnfractions 0.12 .33 .33 +@item +@tab @code{\n} newline +@tab @code{\t} tab +@item +@tab @code{\b} backspace +@tab @code{\r} carriage return +@item +@tab @code{\f} form feed +@tab @code{\v} vertical tab +@item +@tab @code{\a} alert (bell) +@end multitable +@noindent +The combinations @code{\\}, @code{\'}, @code{\"} and @code{\?} can be +used for individual characters. Escape sequences can also use octal +codes @code{\0}--@code{\377} and hexadecimal codes +@code{\0x00}--@code{\0xFF}. + +Example: + +@example +@verbatiminclude msg-unknownesc.c +@end example +@noindent +The escape sequence @code{\N} in the program above is invalid---the +correct escape sequence for a newline is @code{\n}. + +@item warning: suggest parentheses around assignment used as truth value +@cindex suggest parentheses around assignment used as truth value + +This warning highlights a potentially serious error, using the assignment +operator @samp{=} instead of the comparison operator @samp{==} in the +test of a conditional statement or other logical expression. While the +assignment operator can be used as part of a logical value, this is rarely +the intended behavior. + +Example: + +@example +@verbatiminclude msg-assign.c +@end example +@noindent +The test above should be written as @code{if (i == 1)}, otherwise the +variable @code{i} will be set to @code{1} by the evaluation of the if +statement itself. The operator @samp{=} both assigns and returns the +value of its right-hand side, causing the variable @code{i} to be +modified and the unexpected branch taken. Similar unexpected results +occur with @code{if (i = 0)} instead of @code{if (i == 0)}, +except that in this case the body of the @code{if} statement would +never be executed. + +This warning is suppressed if the assignment is enclosed in additional +parentheses to indicate that it is being used legitimately. + + +@item warning: control reaches end of non-void function +@cindex control reaches end of non-void function + +A function which has been declared with a return type, such as +@code{int} or @code{double}, should always have a @code{return} +statement returning a value of the corresponding type at all +possible end points---otherwise its return value is not well-defined. +Functions declared @code{void} do not need @code{return} statements. + +Example: + +@example +@verbatiminclude msg-control.c +@end example +@noindent +The program above reaches the end of the @code{display} function, which has +a return type of @code{int}, without a @code{return} statement. An +additional line such as @code{return 0;} is needed. + +When using @code{gcc} the @code{main} function of a C program must +return a value of type @code{int} (the exit status of the program). In +C++ the @code{return} statement can be omitted from the @code{main} +function---the return value of the C++ @code{main} function defaults +to 0 if unspecified. + +@item warning: unused variable `...' +@itemx warning: unused parameter `...' +@cindex unused variable warning +@cindex unused parameter warning + +These warnings indicate that a variable has been declared as a local +variable or in the parameters of a function, but has not been used +anywhere. An unused variable can be the result of a programming error, +such as accidentally using the name of a different variable in place of +the intended one. + +Example: + +@example +@verbatiminclude msg-unused.c +@end example +@noindent +In this program the variable @code{i} and the parameter @code{p} are +never used. Note that unused variables are reported by @option{-Wall}, +while unused parameters are only shown with @option{-Wall -W}. + +@item warning: passing arg of ... as ... due to prototype +@cindex passing arg of function as another type to prototype + +This warning occurs when a function is called with an argument of a +different type from that specified in the prototype. The option +@option{-Wconversion} is needed to enable this warning. See +the description of @option{-Wconversion} in @ref{Additional warning +options} for an example. + + +@item warning: assignment of read-only location +@itemx warning: cast discards qualifiers from pointer target type +@itemx warning: assignment discards qualifiers ... +@itemx warning: initialization discards qualifiers ... +@itemx warning: return discards qualifiers ... +@cindex assignment of read-only location +@cindex cast discards qualifiers from pointer target type +@cindex assignment discards qualifiers +@cindex initialization discards qualifiers +@cindex return discards qualifiers + +These warnings occur when a pointer is used incorrectly, violating a +type qualifier such as @code{const}. Data accessed through a pointer +marked as @code{const} should not be modified, and the pointer itself +can only be assigned to other pointers that are also marked +@code{const}. + +Example: + +@example +@verbatiminclude msg-const.c +@end example +@noindent +This program attempts to modify constant data, and to discard the +@code{const} property of the argument @code{s} in the return value. + +@item initializer element is not a constant +@cindex initializer element is not a constant + +In C, global variables can only be initialized with constants, such as +numeric values, @code{NULL} or fixed strings. This error occurs if a +non-constant value is used. + +Example: + +@example +@verbatiminclude msg-init.c +@end example +@noindent +This program attempts to initialize two variables from other variables. +In particular, the stream @code{stdout} is not required to be a constant +by the C standard (although on some systems it is a constant). Note +that non-constant initializers are allowed in C++. + +@end table + +@node Linker error messages +@section Linker error messages +@cindex linker, error messages + +@table @code +@item file not recognized: File format not recognized +@cindex file not recognized +@cindex file format not recognized + +GCC uses the extension of a file, such as @file{.c} or @file{.cc}, to +determine its content. If the extension is missing GCC cannot recognize +the file type and will give this error. + +Example: + +@example +@verbatiminclude msg-ext +@end example +@noindent +If the program above is saved in a file @file{hello} without any +extension then compiling it will give the error: + +@example +$ gcc -Wall hello +hello: file not recognized: File format not +recognized +collect2: ld returned 1 exit status +@end example +@noindent +The solution is to rename the file to the correct extension, in this +case @file{hello.c}. + +@item undefined reference to `foo' +@itemx collect2: ld returned 1 exit status +@cindex undefined reference error +@cindex collect2: ld returned 1 exit status +@cindex ld returned 1 exit status + +This error occurs when a program uses a function or variable which is +not defined in any of the object files or libraries supplied to the +linker. It can be caused by a missing library or the use of an +incorrect name. In the error message above, the program +@file{collect2} is part of the linker. + +Example: + +@example +@verbatiminclude msg-undef.c +@end example +@noindent +If this program is compiled without linking to a library or object file +containing the function @code{foo()} there will be an undefined +reference error. + +@item /usr/lib/crt1.o(.text+0x18): undefined reference to `main' +@cindex undefined reference to 'main' + +This error is a special case of the error above, when the missing +function is @code{main}. In C and C++, every program must have a +@code{main} function (where execution starts). When compiling an +individual source file without a @code{main} function, use the option +@option{-c} (@pxref{Creating object files from source files}). + +@end table + + +@node Runtime error messages +@section Runtime error messages +@cindex runtime error messages + +@table @code + +@item error while loading shared libraries: +@itemx cannot open shared object file: No such file or directory +@cindex error while loading shared libraries +@cindex cannot open shared object file +@cindex No such file or directory + +The program uses shared libraries, but the necessary shared library +files cannot be found by the dynamic linker when the program starts. +The search path for shared libraries is controlled by the environment +variable @env{LD_LIBRARY_PATH} (@pxref{Shared libraries and static +libraries}). + +@item Segmentation fault +@itemx Bus error +@cindex segmentation fault +@cindex bus error +@cindex null pointer +@cindex uninitialized pointer +@cindex @code{scanf}, incorrect usage warning +These runtime messages indicate a memory access error. + +Common causes include: + +@itemize @bullet +@item dereferencing a null pointer or uninitialized pointer + +@item out-of-bounds array access + +@item incorrect use of @code{malloc}, @code{free} and related functions + +@item use of @code{scanf} with invalid arguments +@end itemize + +There is a subtle difference between segmentation faults and bus errors. +A segmentation fault occurs when a process tries to access memory +protected by the operating system. A bus error occurs when valid memory +is accessed in an incorrect way (for example, trying to read an +@dfn{unaligned} value on architectures where values must be aligned with +4-byte offsets). + +@item floating point exception +@cindex floating point exception + +This runtime error is caused by an arithmetic exception, such as +division by zero, overflow, underflow or an invalid operation (e.g. +taking the square root of @math{-1}). The operating system determines +which conditions produce this error. On GNU systems, the functions +@code{feenableexcept} and @code{fedisableexcept} can be used to trap or +mask each type of exception. + +@item Illegal instruction +@cindex illegal instruction error + +This error is produced by the operating system when an illegal machine +instruction is encountered. It occurs when code has been compiled for +one specific architecture and run on another. + +@end table + + + +@ignore +@table @code +@item function declaration isn't a prototype + +@item comparison between signed and unsigned +@item too few arguments for format +@item ... used with ... format +@item declared inside parameter list +@item may not appear in macro parameter list +@item ? without following : +@itemx : without preceding ? +@itemx signed and unsigned type in conditional expression +@item conflicting types for .... +@item /* within comment +@item type defaults to `int' in declaration of ... +@item data definition has no type or storage class +@item pointer targets differ in signedness +@item storage size of ... isn't known +@item integer overflow in expression +@item no previous prototype for ... +@item redundant redeclaration of ... +@item array subscript has type char +@item array subscript is not an integer +@item cast from pointer to integer of different size +@item return type defaults to int +@item missing braces around initializer +@item unterminated comment +@item suggest explicit braces to avoid ambiguous else +@item invalid lvalue in assignment +@item function returns address of local variable +@item comparison is always false due to limited range of datatype +@itemx comparison is always true due to limited range of datatype + +can be caused by signed vs unsigned char + +@item excess elements in scalar initializer +@item excess elements in struct initializer +@item excess elements in array initializer + +@item invalid operands to binary ... +@item return with a value in function returning void +@item ... is a GCC extension +@item empty body in an if-statement +@item empty body in an else-statement +@item invalid storage class for function ... +@item unknown escape sequence ... + +@item variable or field ... declared void +@item argument ... doesn't match prototype +@item subscripted value is neither array nor pointer +@item braces around scalar initializer +@item number of arguments doesn't match prototype +@item large integer implicitly truncated to unsigned type +@item integer constant is too large for ... type +@item overflow in implicit constant conversion +@item nested extern declaration of ... +@item parameter has incomplete type +@item return with no value, in function returning non-void +@item no return statement in function returning non-void +@item this function may return with or without a value +@item ... with different width due to prototype + +@item declaration of ... shadows a global declaration +@item declaration of ... shadows a previous local declaration +@item ... of read-only variable +@item initializer element is not computable at load time +@item empty character constant +@item ... has an incomplete type +@item integer constant is so large that it is unsigned +@item backslash and newline separated by space +@item array size missing in ... +@item unrecognized format specifier ... +@item ... as unsigned due to prototype +@item ... as signed due to prototype +@item overflow in constant expression +@item floating point overflow in expression +@item for loop initial declaration used outside C99 mode +@item switch quantity is not an integer +@item too many decimal points in number +@item storage size of ... isn't constant +@item as floating rather than integer due to prototype +@item invalid conversion from ... to ... +@item no matching function for call to ... +@item shadow... + +@end table +@end ignore + @node Getting help @chapter Getting help @cindex getting help -If you encounter a problem not covered by this manual, there are several +If you encounter a problem not covered by this introduction, there are several reference manuals which describe GCC and language-related topics in more detail (@pxref{Further reading}). These manuals contain answers to common questions, and careful study of them will usually yield a -solution. If the manuals are unclear, the most appropriate way to obtain -help is to ask a knowledgeable colleague for assistance. +solution. Alternatively, there are many companies and consultants who offer commercial support for programming matters related to GCC on an hourly @@ -4645,7 +6168,7 @@ obtain high-quality support. @cindex support, commercial -@cindex consultants, providing commercial support +@cindex commercial support A directory of free software support companies and their current rates can be found on the GNU Project website.@footnote{@uref{http://www.gnu.org/prep/service.html}} With free @@ -4672,10 +6195,10 @@ @cindex Using GCC (Reference Manual) @cindex GNU Compilers, Reference Manual -@itemize @asis{} -@item @cite{Using GCC (for GCC version 3.3.1)} by Richard M. Stallman and the GCC Developer Community +@quotation +@cite{Using GCC (for GCC version 3.3.1)} by Richard M. Stallman and the GCC Developer Community (Published by GNU Press, ISBN 1-882114-39-6) -@end itemize +@end quotation @noindent This manual is essential for anyone working with GCC because it describes every option in detail. Note that the manual is updated when @@ -4688,25 +6211,27 @@ @cindex GNU GDB Manual @cindex GNU Make Manual -@itemize @asis{} -@item @cite{Debugging with GDB: The GNU Source-Level Debugger} +@quotation +@cite{Debugging with GDB: The GNU Source-Level Debugger} by Richard M. Stallman, Roland Pesch, Stan Shebs, et al. (Published by GNU Press, ISBN 1-882114-88-4) +@end quotation -@item @cite{GNU Make: A Program for Directing Recompilation} +@quotation +@cite{GNU Make: A Program for Directing Recompilation} by Richard M. Stallman and Roland McGrath (Published by GNU Press, ISBN 1-882114-82-5) -@end itemize +@end quotation @noindent For effective C programming it is also essential to have a good knowledge of the C standard library. The following manual documents all the functions in the GNU C Library: @cindex GNU C Library Reference Manual -@itemize @asis{} -@item @cite{The GNU C Library Reference Manual} +@quotation +@cite{The GNU C Library Reference Manual} by Sandra Loosemore with Richard M. Stallman, et al (2 vols) (Published by GNU Press, ISBN 1-882114-22-1 and 1-882114-24-8) -@end itemize +@end quotation @noindent @cindex GNU Press, manuals Be sure to check the website @uref{http://www.gnupress.org/} for the @@ -4721,12 +6246,11 @@ Information about shell commands, environment variables and shell-quoting rules can be found in the following book: -@itemize @asis -@item +@quotation @uref{http://www.network-theory.co.uk/bash/manual/,@cite{The GNU Bash Reference Manual},@cite{The GNU Bash Reference Manual}} by Chet Ramey and Brian Fox (Published by Network Theory Ltd, ISBN 0-9541617-7-7) -@end itemize +@end quotation @noindent Other GNU Manuals mentioned in this book (such as @cite{GNU gprof---The GNU Profiler} and @cite{The GNU Binutils Manual}) were not available in @@ -4734,68 +6258,66 @@ be found at the publisher's webpage for this book.@footnote{@uref{http://www.network-theory.co.uk/gcc/intro/}} -The official GNU Project webpages for GCC can be found at -@uref{http://www.gnu.org/software/gcc/}. These include a list of +The official GNU Project webpage for GCC can be found on the GNU website +at @uref{http://www.gnu.org/software/gcc/}. This includes a list of frequently asked questions, as well as the GCC bug tracking database and a lot of other useful information about GCC. There are many books about the C and C++ languages themselves. Two of the standard references are: -@cindex reference books, C language +@cindex reference books @cindex C language, further reading @cindex books, further reading @cindex Kernighan and Ritchie, @cite{The C Programming Language} -@itemize @asis{} -@item @cite{The C Programming Language} (ANSI edition) +@quotation +@cite{The C Programming Language} (ANSI edition) Brian W. Kernighan, Dennis Ritchie (ISBN 0-13110362-8) +@end quotation -@item @cite{The C++ Programming Language} (3rd edition) +@quotation +@cite{The C++ Programming Language} (3rd edition) Bjarne Stroustrup (ISBN 0-20188954-4) -@end itemize +@end quotation @noindent +@cindex C library, standard @cindex standards, C, C++ and IEEE arithmetic @cindex IEEE arithmetic standard, printed form @cindex C/C++ languages, standards in printed form @cindex ISO standards for C/C++ languages, available as books @cindex ANSI standards for C/C++ languages, available as books Anyone using the C and C++ languages in a professional context should -obtain a copy of the official language standards. - -The official C standard number is ISO/IEC 9899:1990, for the original C -standard published in 1990 and implemented by GCC. A revised C standard -ISO/IEC 9899:1999 (known as C99) was published in 1999, and this is -mostly (but not yet fully) supported by GCC. - -The C++ standard is ISO/IEC 14882. The IEEE floating-point arithmetic -standard (IEEE-754) is also important for any programs involving -numerical computations. - -These standards documents are available commercially from the relevant -standards bodies. The C and C++ standards are also available as printed -books: +obtain a copy of the official language standards, which are also +available as printed books: -@itemize @asis{} -@item @cite{The C Standard: Incorporating Technical Corrigendum 1} +@quotation +@cite{The C Standard: Incorporating Technical Corrigendum 1} (Published by Wiley, ISBN 0-470-84573-2) +@end quotation -@item @cite{The C++ Standard} +@quotation +@cite{The C++ Standard} (Published by Wiley, ISBN 0-470-84674-7) -@end itemize - -For ongoing learning, anyone using GCC might consider joining the -Association of C and C++ Users (ACCU). The ACCU is a non-profit -organization devoted to professionalism in programming at all levels, -and is recognized as an authority in the field. More information is -available from the ACCU website @uref{http://www.accu.org/}. - -@cindex journals, about C and C++ programming -@cindex ACCU, Association of C and C++ users -@cindex Association of C and C++ users (ACCU) -The ACCU publishes two journals about programming in C and C++ and -organizes regular conferences. The annual membership fee represents a -good investment for individuals, or for companies who want to encourage -a higher standard of professional development among their staff. +@end quotation +@noindent +For reference, the C standard number is ISO/IEC 9899:1990, for the +original C standard published in 1990 and implemented by GCC. A revised +C standard ISO/IEC 9899:1999 (known as C99) was published in 1999, and +this is mostly (but not yet fully) supported by GCC. The C++ standard +is ISO/IEC 14882. + +@cindex IEEE-754 standard +The floating-point arithmetic standard IEEE-754 is important for any +programs involving numerical computations. The standard is available +commercially from the IEEE, and is also described in the following book: + +@quotation +@cite{Numerical Computing with IEEE Floating Point Arithmetic} +by Michael Overton (Published by SIAM, ISBN 0-89871-482-6). +@end quotation +@noindent +The book includes many examples to illustrate the rationale for the +standard. @node Acknowledgements @unnumbered Acknowledgements @@ -4814,7 +6336,8 @@ Thanks to Jamie Lokier, for research. -Thanks to Stephen Compall, for helpful corrections. +Thanks to Martin Leisner, Mario Pernici, Stephen Compall and Nigel +Lowry, for helpful corrections. Thanks to Gerard Jungman, for useful comments. @@ -4824,14 +6347,17 @@ And most importantly, thanks to Richard Stallman, founder of the GNU Project, for writing GCC and making it free software. -@ifnotinfo @page +@node Other books from the publisher @unnumbered Other books from the publisher @include books.texi +@node Free software organizations @unnumbered Free software organizations @include associations.texi +@ifnotinfo +@node GNU Free Documentation License @unnumbered GNU Free Documentation License @include fdl.texi @end ifnotinfo @@ -4847,8 +6373,8 @@ @page @headings off @* -@page -@* +@c @page +@c @* @c @page @c @* @c @page diff -Naur -x '*.info' gccintro-1.0/grid.h gccintro-1.1/grid.h --- gccintro-1.0/grid.h 2003-10-14 15:14:33.000000000 +0100 +++ gccintro-1.1/grid.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,24 +0,0 @@ -template class Grid { -public: - Grid(int x, int y); - void set(int x, int y, T f); - T get(int x, int y); -private: - int nx; - int ny; - T * pT; -}; - -template Grid::Grid(int x, int y) { - nx = x; - ny = y; - pT = new T[nx * ny]; -}; - -template void Grid::set(int x, int y, T f) { - pT[x*ny+y] = f; -}; - -template T Grid::get(int x, int y) { - return pT[x*ny+y]; -}; diff -Naur -x '*.info' gccintro-1.0/heap.c gccintro-1.1/heap.c --- gccintro-1.0/heap.c 2003-09-29 14:46:32.000000000 +0100 +++ gccintro-1.1/heap.c 1970-01-01 01:00:00.000000000 +0100 @@ -1,52 +0,0 @@ -void -swap (double *base, int i, int j) -{ - double tmp = base[i]; - base[i] = base[j]; - base[j] = tmp; -} - -void -downheap (double *data, const int N, int k) -{ - while (k <= N / 2) - { - int j = 2 * k; - if (j < N && (data[j] < data[j + 1])) - j++; - if (data[k] < data[j]) - swap (data, j, k); - else - break; - k = j; - } -} - -void -heapsort (double *data, int count) -{ - int N = count - 1, k = (N / 2) + 1; - do { downheap (data, N, --k); } while (k > 0); - while (N > 0) { - swap (data, 0, N); - downheap (data, --N, 0); - } -} - -#include -#include - -int -main (void) -{ - int i, N = 1000000; - double *x = malloc (N * sizeof (double)); - - for (i = 0; i < N; i++) - x[i] = N / (1.0 + i); - - heapsort (x, N); - - for (i = 0; i < N; i++) - printf ("%d %g\n", i, x[i]); -} diff -Naur -x '*.info' gccintro-1.0/hello2.c gccintro-1.1/hello2.c --- gccintro-1.0/hello2.c 2004-02-05 15:22:39.000000000 +0000 +++ gccintro-1.1/hello2.c 1970-01-01 01:00:00.000000000 +0100 @@ -1,8 +0,0 @@ -#include -#include "hello.h" - -void -hello (const char * name) -{ - printf ("Good morning, %s!\n", name); -} diff -Naur -x '*.info' gccintro-1.0/hellobad.c gccintro-1.1/hellobad.c --- gccintro-1.0/hellobad.c 2003-08-11 14:29:42.000000000 +0100 +++ gccintro-1.1/hellobad.c 1970-01-01 01:00:00.000000000 +0100 @@ -1,6 +0,0 @@ -int -main (void) -{ - printf ("Hello, world!\n"); - return 0; -} diff -Naur -x '*.info' gccintro-1.0/hello.cc gccintro-1.1/hello.cc --- gccintro-1.0/hello.cc 2004-01-29 17:25:59.000000000 +0000 +++ gccintro-1.1/hello.cc 2004-07-13 11:38:40.000000000 +0100 @@ -3,6 +3,6 @@ int main () { - std::cout << "Hello, world!" << std::endl; + std::cout << "Hello, world!\n"; return 0; } diff -Naur -x '*.info' gccintro-1.0/hellocc.c gccintro-1.1/hellocc.c --- gccintro-1.0/hellocc.c 2004-03-28 14:20:47.000000000 +0100 +++ gccintro-1.1/hellocc.c 1970-01-01 01:00:00.000000000 +0100 @@ -1,8 +0,0 @@ -#include - -int -main () -{ - std::cout << "Hello, world!" << std::endl; - return 0; -} diff -Naur -x '*.info' gccintro-1.0/hellostr.cc gccintro-1.1/hellostr.cc --- gccintro-1.0/hellostr.cc 2003-10-14 15:36:13.000000000 +0100 +++ gccintro-1.1/hellostr.cc 2004-07-13 11:46:02.000000000 +0100 @@ -8,6 +8,6 @@ { string s1 = "Hello,"; string s2 = "World!"; - cout << s1 + " " + s2 << endl; + cout << s1 + " " + s2 << '\n'; return 0; } diff -Naur -x '*.info' gccintro-1.0/inline2.c gccintro-1.1/inline2.c --- gccintro-1.0/inline2.c 2003-09-26 14:34:28.000000000 +0100 +++ gccintro-1.1/inline2.c 1970-01-01 01:00:00.000000000 +0100 @@ -1,16 +0,0 @@ -#include -#include - -int -main (void) -{ - int i; - double sum = 0; - - for (i = 0; i < 1e7; i++) - sum += (i + 0.5) * (i + 0.5); - - printf ("sum = %g\n", sum); - - return 0; -} diff -Naur -x '*.info' gccintro-1.0/inline.c gccintro-1.1/inline.c --- gccintro-1.0/inline.c 2004-01-29 16:37:35.000000000 +0000 +++ gccintro-1.1/inline.c 1970-01-01 01:00:00.000000000 +0100 @@ -1,17 +0,0 @@ -#include - -double -sq (double x) -{ - return x * x; -} - -int -main (void) -{ - int i; - double sum = 0; - for (i = 0; i < 100000000; i++) - sum += sq (i + 0.5); - return 0; -} diff -Naur -x '*.info' gccintro-1.0/loop.c gccintro-1.1/loop.c --- gccintro-1.0/loop.c 1970-01-01 01:00:00.000000000 +0100 +++ gccintro-1.1/loop.c 2005-07-04 15:49:08.000000000 +0100 @@ -0,0 +1,7 @@ +int +main (void) +{ + usigned int i = 0; + while (1) { i++; }; + return 0; +} diff -Naur -x '*.info' gccintro-1.0/Makefile.am gccintro-1.1/Makefile.am --- gccintro-1.0/Makefile.am 2004-05-06 14:46:33.000000000 +0100 +++ gccintro-1.1/Makefile.am 2005-08-20 17:26:54.000000000 +0100 @@ -1,5 +1,5 @@ info_TEXINFOS = gccintro.texi gccintro_TEXINFOS = fdl.texi books.texi associations.texi rms.texi -EXTRA_DIST = alpha.c ansi.c bad.c badpow.c bye_fn.c calc.c calc2.c castqual.c check.c collatz.c cov.c dbmain.c dtest.c dtestval.c dtestval2.c dtestval3.c gnuarray.c heap.c hello.c hello2.c hello_fn.c hellobad.c hellocc.c inline.c inline2.c main.c main2.c main3.c main4.c nested.c null.c optim.c pi.c prof.c readdir.c shadow.c shadow2.c stl2.c stl3.c sus.c test.c uninit.c uninit2.c w.c whetstone.c buffer.h grid.h hello.h hello1.h tprint.h hello.cc hellostr.cc string.cc templates.cc templates2.cc tmain.cc tmp.cc tprint.cc tprog.cc cov_c_gcov COPYING.FDL +EXTRA_DIST = hello.c bad.c main.c hello1.h hello_fn.c main2.c c1makefile2 calc.c badpow.c dbmain.c ansi.c pi.c gnuarray.c main4.c w.c wabs.c shadow.c shadow2.c castqual.c dtest.c dtestval.c dtestval2.c dtestval3.c test.c hello.c null.c optim.c uninit.c hello.cc hellostr.cc string.cc buffer.h tprog.cc templates.cc templates2.cc alpha.c setfpu.c fptest2.c signed.c testgetc.c testgetc2.c loop.c hello_fn.c bye_fn.c hello.h main3.c collatz.c cov.c cov_c_gcov hello.c msg-file.c msg-nest1.h msg-nest2.h msg-invalidpp.c msg-cppheader.c msg-undeclared.c msg-parse.c msg-eoi.c msg-implicitdecl.c msg-unterm.c msg-string2.c msg-string2.cc msg-char.c msg-null.c msg-derefincomplete.c msg-unknownesc.c msg-assign.c msg-control.c msg-unused.c msg-const.c msg-init.c msg-ext msg-undef.c COPYING.FDL diff -Naur -x '*.info' gccintro-1.0/Makefile.in gccintro-1.1/Makefile.in --- gccintro-1.0/Makefile.in 2004-05-06 14:47:09.000000000 +0100 +++ gccintro-1.1/Makefile.in 2005-08-20 17:27:02.000000000 +0100 @@ -1,8 +1,8 @@ -# Makefile.in generated by automake 1.7.5 from Makefile.am. +# Makefile.in generated by automake 1.9.6 from Makefile.am. # @configure_input@ -# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 -# Free Software Foundation, Inc. +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -13,7 +13,6 @@ # PARTICULAR PURPOSE. @SET_MAKE@ - srcdir = @srcdir@ top_srcdir = @top_srcdir@ VPATH = @srcdir@ @@ -21,7 +20,6 @@ pkglibdir = $(libdir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ top_builddir = . - am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd INSTALL = @INSTALL@ install_sh_DATA = $(install_sh) -c -m 644 @@ -35,6 +33,47 @@ NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : +subdir = . +DIST_COMMON = README $(am__configure_deps) $(gccintro_TEXINFOS) \ + $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ + $(top_srcdir)/configure AUTHORS ChangeLog INSTALL NEWS \ + install-sh missing mkinstalldirs texinfo.tex +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ + configure.lineno configure.status.lineno +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_CLEAN_FILES = +depcomp = +am__depfiles_maybe = +SOURCES = +DIST_SOURCES = +INFO_DEPS = $(srcdir)/gccintro.info +am__TEXINFO_TEX_DIR = $(srcdir) +DVIS = gccintro.dvi +PDFS = gccintro.pdf +PSS = gccintro.ps +HTMLS = gccintro.html +TEXINFOS = gccintro.texi +TEXI2DVI = texi2dvi +TEXI2PDF = $(TEXI2DVI) --pdf --batch +MAKEINFOHTML = $(MAKEINFO) --html +AM_MAKEINFOHTMLFLAGS = $(AM_MAKEINFOFLAGS) +DVIPS = dvips +am__installdirs = "$(DESTDIR)$(infodir)" +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +distdir = $(PACKAGE)-$(VERSION) +top_distdir = $(distdir) +am__remove_distdir = \ + { test ! -d $(distdir) \ + || { find $(distdir) -type d ! -perm -200 -exec chmod u+w {} ';' \ + && rm -fr $(distdir); }; } +DIST_ARCHIVES = $(distdir).tar.gz +GZIP_ENV = --best +distuninstallcheck_listfiles = find . -type f -print +distcleancheck_listfiles = find . -type f -print ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AUTOCONF = @AUTOCONF@ @@ -67,6 +106,8 @@ VERSION = @VERSION@ ac_ct_STRIP = @ac_ct_STRIP@ am__leading_dot = @am__leading_dot@ +am__tar = @am__tar@ +am__untar = @am__untar@ bindir = @bindir@ build_alias = @build_alias@ datadir = @datadir@ @@ -79,6 +120,7 @@ libexecdir = @libexecdir@ localstatedir = @localstatedir@ mandir = @mandir@ +mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ prefix = @prefix@ program_transform_name = @program_transform_name@ @@ -88,77 +130,107 @@ target_alias = @target_alias@ info_TEXINFOS = gccintro.texi gccintro_TEXINFOS = fdl.texi books.texi associations.texi rms.texi -EXTRA_DIST = alpha.c ansi.c bad.c badpow.c bye_fn.c calc.c calc2.c castqual.c check.c collatz.c cov.c dbmain.c dtest.c dtestval.c dtestval2.c dtestval3.c gnuarray.c heap.c hello.c hello2.c hello_fn.c hellobad.c hellocc.c inline.c inline2.c main.c main2.c main3.c main4.c nested.c null.c optim.c pi.c prof.c readdir.c shadow.c shadow2.c stl2.c stl3.c sus.c test.c uninit.c uninit2.c w.c whetstone.c buffer.h grid.h hello.h hello1.h tprint.h hello.cc hellostr.cc string.cc templates.cc templates2.cc tmain.cc tmp.cc tprint.cc tprog.cc cov_c_gcov COPYING.FDL -subdir = . -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs -CONFIG_CLEAN_FILES = -depcomp = -am__depfiles_maybe = -DIST_SOURCES = -am__TEXINFO_TEX_DIR = $(srcdir) -INFO_DEPS = gccintro.info -DVIS = gccintro.dvi -PDFS = gccintro.pdf -PSS = gccintro.ps -TEXINFOS = gccintro.texi -DIST_COMMON = README $(gccintro_TEXINFOS) AUTHORS ChangeLog INSTALL \ - Makefile.am Makefile.in NEWS aclocal.m4 configure configure.ac \ - install-sh missing mkinstalldirs texinfo.tex +EXTRA_DIST = hello.c bad.c main.c hello1.h hello_fn.c main2.c c1makefile2 calc.c badpow.c dbmain.c ansi.c pi.c gnuarray.c main4.c w.c wabs.c shadow.c shadow2.c castqual.c dtest.c dtestval.c dtestval2.c dtestval3.c test.c hello.c null.c optim.c uninit.c hello.cc hellostr.cc string.cc buffer.h tprog.cc templates.cc templates2.cc alpha.c setfpu.c fptest2.c signed.c testgetc.c testgetc2.c loop.c hello_fn.c bye_fn.c hello.h main3.c collatz.c cov.c cov_c_gcov hello.c msg-file.c msg-nest1.h msg-nest2.h msg-invalidpp.c msg-cppheader.c msg-undeclared.c msg-parse.c msg-eoi.c msg-implicitdecl.c msg-unterm.c msg-string2.c msg-string2.cc msg-char.c msg-null.c msg-derefincomplete.c msg-unknownesc.c msg-assign.c msg-control.c msg-unused.c msg-const.c msg-init.c msg-ext msg-undef.c COPYING.FDL all: all-am .SUFFIXES: -.SUFFIXES: .dvi .info .pdf .ps .texi - -am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ - configure.lineno -$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.ac $(ACLOCAL_M4) +.SUFFIXES: .dvi .html .info .pdf .ps .texi +am--refresh: + @: +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + echo ' cd $(srcdir) && $(AUTOMAKE) --foreign --ignore-deps'; \ + cd $(srcdir) && $(AUTOMAKE) --foreign --ignore-deps \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign --ignore-deps Makefile'; \ cd $(top_srcdir) && \ - $(AUTOMAKE) --gnu Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe) + $(AUTOMAKE) --foreign --ignore-deps Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + echo ' $(SHELL) ./config.status'; \ + $(SHELL) ./config.status;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \ + esac; -$(top_builddir)/config.status: $(srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) $(SHELL) ./config.status --recheck -$(srcdir)/configure: $(srcdir)/configure.ac $(ACLOCAL_M4) $(CONFIGURE_DEPENDENCIES) - cd $(srcdir) && $(AUTOCONF) -$(ACLOCAL_M4): configure.ac +$(top_srcdir)/configure: $(am__configure_deps) + cd $(srcdir) && $(AUTOCONF) +$(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) .texi.info: - @rm -f $@ $@-[0-9] $@-[0-9][0-9] $(@:.info=).i[0-9] $(@:.info=).i[0-9][0-9] - $(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -I $(srcdir) \ - -o $@ `test -f '$<' || echo '$(srcdir)/'`$< + restore=: && backupdir="$(am__leading_dot)am$$$$" && \ + am__cwd=`pwd` && cd $(srcdir) && \ + rm -rf $$backupdir && mkdir $$backupdir && \ + if ($(MAKEINFO) --version) >/dev/null 2>&1; then \ + for f in $@ $@-[0-9] $@-[0-9][0-9] $(@:.info=).i[0-9] $(@:.info=).i[0-9][0-9]; do \ + if test -f $$f; then mv $$f $$backupdir; restore=mv; else :; fi; \ + done; \ + else :; fi && \ + cd "$$am__cwd"; \ + if $(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -I $(srcdir) \ + -o $@ $<; \ + then \ + rc=0; \ + cd $(srcdir); \ + else \ + rc=$$?; \ + cd $(srcdir) && \ + $$restore $$backupdir/* `echo "./$@" | sed 's|[^/]*$$||'`; \ + fi; \ + rm -rf $$backupdir; exit $$rc .texi.dvi: TEXINPUTS="$(am__TEXINFO_TEX_DIR)$(PATH_SEPARATOR)$$TEXINPUTS" \ MAKEINFO='$(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -I $(srcdir)' \ - $(TEXI2DVI) `test -f '$<' || echo '$(srcdir)/'`$< + $(TEXI2DVI) $< .texi.pdf: TEXINPUTS="$(am__TEXINFO_TEX_DIR)$(PATH_SEPARATOR)$$TEXINPUTS" \ MAKEINFO='$(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -I $(srcdir)' \ - $(TEXI2PDF) `test -f '$<' || echo '$(srcdir)/'`$< -gccintro.info: gccintro.texi $(gccintro_TEXINFOS) + $(TEXI2PDF) $< + +.texi.html: + rm -rf $(@:.html=.htp) + if $(MAKEINFOHTML) $(AM_MAKEINFOHTMLFLAGS) $(MAKEINFOFLAGS) -I $(srcdir) \ + -o $(@:.html=.htp) $<; \ + then \ + rm -rf $@; \ + if test ! -d $(@:.html=.htp) && test -d $(@:.html=); then \ + mv $(@:.html=) $@; else mv $(@:.html=.htp) $@; fi; \ + else \ + if test ! -d $(@:.html=.htp) && test -d $(@:.html=); then \ + rm -rf $(@:.html=); else rm -Rf $(@:.html=.htp) $@; fi; \ + exit 1; \ + fi +$(srcdir)/gccintro.info: gccintro.texi $(gccintro_TEXINFOS) gccintro.dvi: gccintro.texi $(gccintro_TEXINFOS) gccintro.pdf: gccintro.texi $(gccintro_TEXINFOS) -TEXI2DVI = texi2dvi - -TEXI2PDF = $(TEXI2DVI) --pdf --batch -DVIPS = dvips +gccintro.html: gccintro.texi $(gccintro_TEXINFOS) .dvi.ps: + TEXINPUTS="$(am__TEXINFO_TEX_DIR)$(PATH_SEPARATOR)$$TEXINPUTS" \ $(DVIPS) -o $@ $< uninstall-info-am: - $(PRE_UNINSTALL) + @$(PRE_UNINSTALL) @if (install-info --version && \ - install-info --version | grep -i -v debian) >/dev/null 2>&1; then \ + install-info --version 2>&1 | sed 1q | grep -i -v debian) >/dev/null 2>&1; then \ list='$(INFO_DEPS)'; \ for file in $$list; do \ relfile=`echo "$$file" | sed 's|^.*/||'`; \ - echo " install-info --info-dir=$(DESTDIR)$(infodir) --remove $(DESTDIR)$(infodir)/$$relfile"; \ - install-info --info-dir=$(DESTDIR)$(infodir) --remove $(DESTDIR)$(infodir)/$$relfile; \ + echo " install-info --info-dir='$(DESTDIR)$(infodir)' --remove '$(DESTDIR)$(infodir)/$$relfile'"; \ + install-info --info-dir="$(DESTDIR)$(infodir)" --remove "$(DESTDIR)$(infodir)/$$relfile"; \ done; \ else :; fi @$(NORMAL_UNINSTALL) @@ -166,15 +238,19 @@ for file in $$list; do \ relfile=`echo "$$file" | sed 's|^.*/||'`; \ relfile_i=`echo "$$relfile" | sed 's|\.info$$||;s|$$|.i|'`; \ - (if cd $(DESTDIR)$(infodir); then \ - echo " rm -f $$relfile $$relfile-[0-9] $$relfile-[0-9][0-9] $$relfile_i[0-9] $$relfile_i[0-9][0-9])"; \ + (if cd "$(DESTDIR)$(infodir)"; then \ + echo " cd '$(DESTDIR)$(infodir)' && rm -f $$relfile $$relfile-[0-9] $$relfile-[0-9][0-9] $$relfile_i[0-9] $$relfile_i[0-9][0-9]"; \ rm -f $$relfile $$relfile-[0-9] $$relfile-[0-9][0-9] $$relfile_i[0-9] $$relfile_i[0-9][0-9]; \ else :; fi); \ done dist-info: $(INFO_DEPS) + @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ list='$(INFO_DEPS)'; \ for base in $$list; do \ + case $$base in \ + $(srcdir)/*) base=`echo "$$base" | sed "s|^$$srcdirstrip/||"`;; \ + esac; \ if test -f $$base; then d=.; else d=$(srcdir); fi; \ for file in $$d/$$base*; do \ relfile=`expr "$$file" : "$$d/\(.*\)"`; \ @@ -184,11 +260,11 @@ done mostlyclean-aminfo: - -rm -f gccintro.aux gccintro.cp gccintro.cps gccintro.fn gccintro.fns \ + -rm -rf gccintro.aux gccintro.cp gccintro.cps gccintro.fn gccintro.fns \ gccintro.ky gccintro.kys gccintro.log gccintro.pg \ gccintro.pgs gccintro.tmp gccintro.toc gccintro.tp \ gccintro.tps gccintro.vr gccintro.vrs gccintro.dvi \ - gccintro.pdf gccintro.ps + gccintro.pdf gccintro.ps gccintro.html maintainer-clean-aminfo: @list='$(INFO_DEPS)'; for i in $$list; do \ @@ -202,19 +278,6 @@ ctags: CTAGS CTAGS: -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) - -top_distdir = . -distdir = $(PACKAGE)-$(VERSION) - -am__remove_distdir = \ - { test ! -d $(distdir) \ - || { find $(distdir) -type d ! -perm -200 -exec chmod u+w {} ';' \ - && rm -fr $(distdir); }; } - -GZIP_ENV = --best -distuninstallcheck_listfiles = find . -type f -print -distcleancheck_listfiles = find . -type f -print distdir: $(DISTFILES) $(am__remove_distdir) @@ -230,7 +293,7 @@ dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ if test "$$dir" != "$$file" && test "$$dir" != "."; then \ dir="/$$dir"; \ - $(mkinstalldirs) "$(distdir)$$dir"; \ + $(mkdir_p) "$(distdir)$$dir"; \ else \ dir=''; \ fi; \ @@ -254,19 +317,46 @@ ! -type d ! -perm -444 -exec $(SHELL) $(install_sh) -c -m a+r {} {} \; \ || chmod -R a+r $(distdir) dist-gzip: distdir - $(AMTAR) chof - $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz + tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz + $(am__remove_distdir) + +dist-bzip2: distdir + tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2 + $(am__remove_distdir) + +dist-tarZ: distdir + tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z + $(am__remove_distdir) + +dist-shar: distdir + shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz + $(am__remove_distdir) + +dist-zip: distdir + -rm -f $(distdir).zip + zip -rq $(distdir).zip $(distdir) $(am__remove_distdir) dist dist-all: distdir - $(AMTAR) chof - $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz + tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz $(am__remove_distdir) # This target untars the dist file and tries a VPATH configuration. Then # it guarantees that the distribution is self-contained by making another # tarfile. distcheck: dist - $(am__remove_distdir) - GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(AMTAR) xf - + case '$(DIST_ARCHIVES)' in \ + *.tar.gz*) \ + GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(am__untar) ;;\ + *.tar.bz2*) \ + bunzip2 -c $(distdir).tar.bz2 | $(am__untar) ;;\ + *.tar.Z*) \ + uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ + *.shar.gz*) \ + GZIP=$(GZIP_ENV) gunzip -c $(distdir).shar.gz | unshar ;;\ + *.zip*) \ + unzip $(distdir).zip ;;\ + esac chmod -R a-w $(distdir); chmod a+w $(distdir) mkdir $(distdir)/_build mkdir $(distdir)/_inst @@ -286,19 +376,20 @@ distuninstallcheck \ && chmod -R a-w "$$dc_install_base" \ && ({ \ - (cd ../.. && $(mkinstalldirs) "$$dc_destdir") \ + (cd ../.. && umask 077 && mkdir "$$dc_destdir") \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \ distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \ } || { rm -rf "$$dc_destdir"; exit 1; }) \ && rm -rf "$$dc_destdir" \ - && $(MAKE) $(AM_MAKEFLAGS) dist-gzip \ - && rm -f $(distdir).tar.gz \ + && $(MAKE) $(AM_MAKEFLAGS) dist \ + && rm -rf $(DIST_ARCHIVES) \ && $(MAKE) $(AM_MAKEFLAGS) distcleancheck $(am__remove_distdir) - @echo "$(distdir).tar.gz is ready for distribution" | \ - sed 'h;s/./=/g;p;x;p;x' + @(echo "$(distdir) archives ready for distribution: "; \ + list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \ + sed -e '1{h;s/./=/g;p;x;}' -e '$${p;x;}' distuninstallcheck: @cd $(distuninstallcheck_dir) \ && test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \ @@ -320,9 +411,10 @@ check-am: all-am check: check-am all-am: Makefile $(INFO_DEPS) - installdirs: - $(mkinstalldirs) $(DESTDIR)$(infodir) + for dir in "$(DESTDIR)$(infodir)"; do \ + test -z "$$dir" || $(mkdir_p) "$$dir"; \ + done install: install-am install-exec: install-exec-am install-data: install-data-am @@ -334,7 +426,7 @@ installcheck: installcheck-am install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - INSTALL_STRIP_FLAG=-s \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: @@ -342,7 +434,7 @@ clean-generic: distclean-generic: - -rm -f Makefile $(CONFIG_CLEAN_FILES) + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @@ -353,12 +445,17 @@ distclean: distclean-am -rm -f $(am__CONFIG_DISTCLEAN_FILES) + -rm -f Makefile distclean-am: clean-am distclean-generic dvi: dvi-am dvi-am: $(DVIS) +html: html-am + +html-am: $(HTMLS) + info: info-am info-am: $(INFO_DEPS) @@ -371,28 +468,32 @@ install-info-am: $(INFO_DEPS) @$(NORMAL_INSTALL) - $(mkinstalldirs) $(DESTDIR)$(infodir) - @list='$(INFO_DEPS)'; \ + test -z "$(infodir)" || $(mkdir_p) "$(DESTDIR)$(infodir)" + @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + list='$(INFO_DEPS)'; \ for file in $$list; do \ + case $$file in \ + $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + esac; \ if test -f $$file; then d=.; else d=$(srcdir); fi; \ file_i=`echo "$$file" | sed 's|\.info$$||;s|$$|.i|'`; \ for ifile in $$d/$$file $$d/$$file-[0-9] $$d/$$file-[0-9][0-9] \ $$d/$$file_i[0-9] $$d/$$file_i[0-9][0-9] ; do \ if test -f $$ifile; then \ relfile=`echo "$$ifile" | sed 's|^.*/||'`; \ - echo " $(INSTALL_DATA) $$ifile $(DESTDIR)$(infodir)/$$relfile"; \ - $(INSTALL_DATA) $$ifile $(DESTDIR)$(infodir)/$$relfile; \ + echo " $(INSTALL_DATA) '$$ifile' '$(DESTDIR)$(infodir)/$$relfile'"; \ + $(INSTALL_DATA) "$$ifile" "$(DESTDIR)$(infodir)/$$relfile"; \ else : ; fi; \ done; \ done @$(POST_INSTALL) @if (install-info --version && \ - install-info --version | grep -i -v debian) >/dev/null 2>&1; then \ + install-info --version 2>&1 | sed 1q | grep -i -v debian) >/dev/null 2>&1; then \ list='$(INFO_DEPS)'; \ for file in $$list; do \ relfile=`echo "$$file" | sed 's|^.*/||'`; \ - echo " install-info --info-dir=$(DESTDIR)$(infodir) $(DESTDIR)$(infodir)/$$relfile";\ - install-info --info-dir=$(DESTDIR)$(infodir) $(DESTDIR)$(infodir)/$$relfile || :;\ + echo " install-info --info-dir='$(DESTDIR)$(infodir)' '$(DESTDIR)$(infodir)/$$relfile'";\ + install-info --info-dir="$(DESTDIR)$(infodir)" "$(DESTDIR)$(infodir)/$$relfile" || :;\ done; \ else : ; fi install-man: @@ -401,7 +502,8 @@ maintainer-clean: maintainer-clean-am -rm -f $(am__CONFIG_DISTCLEAN_FILES) - -rm -rf autom4te.cache + -rm -rf $(top_srcdir)/autom4te.cache + -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-aminfo \ maintainer-clean-generic @@ -419,9 +521,10 @@ uninstall-am: uninstall-info-am -.PHONY: all all-am check check-am clean clean-generic dist dist-all \ - dist-gzip dist-info distcheck distclean distclean-generic \ - distcleancheck distdir distuninstallcheck dvi dvi-am info \ +.PHONY: all all-am am--refresh check check-am clean clean-generic dist \ + dist-all dist-bzip2 dist-gzip dist-info dist-shar dist-tarZ \ + dist-zip distcheck distclean distclean-generic distcleancheck \ + distdir distuninstallcheck dvi dvi-am html html-am info \ info-am install install-am install-data install-data-am \ install-exec install-exec-am install-info install-info-am \ install-man install-strip installcheck installcheck-am \ diff -Naur -x '*.info' gccintro-1.0/msg-assign.c gccintro-1.1/msg-assign.c --- gccintro-1.0/msg-assign.c 1970-01-01 01:00:00.000000000 +0100 +++ gccintro-1.1/msg-assign.c 2005-05-26 16:08:35.000000000 +0100 @@ -0,0 +1,11 @@ +#include + +int +main (void) +{ + int i = 0; + if (i = 1) { /* = should be == */ + printf ("unexpected result\n"); + } + return 0; +} diff -Naur -x '*.info' gccintro-1.0/msg-char.c gccintro-1.1/msg-char.c --- gccintro-1.0/msg-char.c 1970-01-01 01:00:00.000000000 +0100 +++ gccintro-1.1/msg-char.c 2005-05-24 17:42:27.000000000 +0100 @@ -0,0 +1,6 @@ +int +main (void) +{ + char c = "\n"; /* incorrect */ + return 0; +} diff -Naur -x '*.info' gccintro-1.0/msg-const.c gccintro-1.1/msg-const.c --- gccintro-1.0/msg-const.c 1970-01-01 01:00:00.000000000 +0100 +++ gccintro-1.1/msg-const.c 2005-05-31 19:59:38.000000000 +0100 @@ -0,0 +1,6 @@ +char * +f (const char *s) +{ + *s = '\0'; /* assigns to read-only data */ + return s; /* discards const */ +} diff -Naur -x '*.info' gccintro-1.0/msg-control.c gccintro-1.1/msg-control.c --- gccintro-1.0/msg-control.c 1970-01-01 01:00:00.000000000 +0100 +++ gccintro-1.1/msg-control.c 2005-07-05 12:11:07.000000000 +0100 @@ -0,0 +1,7 @@ +#include + +int +display (const char * str) +{ + printf ("%s\n", str); +} diff -Naur -x '*.info' gccintro-1.0/msg-cppheader.c gccintro-1.1/msg-cppheader.c --- gccintro-1.0/msg-cppheader.c 1970-01-01 01:00:00.000000000 +0100 +++ gccintro-1.1/msg-cppheader.c 2005-05-24 17:38:31.000000000 +0100 @@ -0,0 +1,8 @@ +#include /* old style */ + +int +main (void) +{ + cout << "Hello World!\n"; + return 0; +} diff -Naur -x '*.info' gccintro-1.0/msg-derefincomplete.c gccintro-1.1/msg-derefincomplete.c --- gccintro-1.0/msg-derefincomplete.c 1970-01-01 01:00:00.000000000 +0100 +++ gccintro-1.1/msg-derefincomplete.c 2005-05-24 17:46:30.000000000 +0100 @@ -0,0 +1,8 @@ +struct btree * data; + +int +main (void) +{ + data->size = 0; /* incomplete type */ + return 0; +} diff -Naur -x '*.info' gccintro-1.0/msg-eoi.c gccintro-1.1/msg-eoi.c --- gccintro-1.0/msg-eoi.c 1970-01-01 01:00:00.000000000 +0100 +++ gccintro-1.1/msg-eoi.c 2005-05-24 17:40:00.000000000 +0100 @@ -0,0 +1,9 @@ +#include + +int +main (void) +{ + if (1) { + printf ("Hello World!\n"); + return 0; /* no closing brace */ +} diff -Naur -x '*.info' gccintro-1.0/msg-ext gccintro-1.1/msg-ext --- gccintro-1.0/msg-ext 1970-01-01 01:00:00.000000000 +0100 +++ gccintro-1.1/msg-ext 2005-04-20 16:33:47.000000000 +0100 @@ -0,0 +1,8 @@ +#include + +int +main (void) +{ + printf ("Hello World!\n"); + return 0; +} diff -Naur -x '*.info' gccintro-1.0/msg-file.c gccintro-1.1/msg-file.c --- gccintro-1.0/msg-file.c 1970-01-01 01:00:00.000000000 +0100 +++ gccintro-1.1/msg-file.c 2005-05-24 17:38:07.000000000 +0100 @@ -0,0 +1,8 @@ +#include /* incorrect */ + +int +main (void) +{ + printf ("Hello World!\n"); + return 0; +} diff -Naur -x '*.info' gccintro-1.0/msg-implicitdecl.c gccintro-1.1/msg-implicitdecl.c --- gccintro-1.0/msg-implicitdecl.c 1970-01-01 01:00:00.000000000 +0100 +++ gccintro-1.1/msg-implicitdecl.c 2005-05-24 17:39:37.000000000 +0100 @@ -0,0 +1,6 @@ +int +main (void) +{ + printf ("Hello World!\n"); /* no header */ + return 0; +} diff -Naur -x '*.info' gccintro-1.0/msg-init.c gccintro-1.1/msg-init.c --- gccintro-1.0/msg-init.c 1970-01-01 01:00:00.000000000 +0100 +++ gccintro-1.1/msg-init.c 2005-05-30 11:28:00.000000000 +0100 @@ -0,0 +1,12 @@ +#include + +FILE *stream = stdout; /* not constant */ +int i = 10; +int j = 2 * i; /* not constant */ + +int +main (void) +{ + fprintf (stream, "Hello World!\n"); + return 0; +} diff -Naur -x '*.info' gccintro-1.0/msg-invalidpp.c gccintro-1.1/msg-invalidpp.c --- gccintro-1.0/msg-invalidpp.c 1970-01-01 01:00:00.000000000 +0100 +++ gccintro-1.1/msg-invalidpp.c 2005-05-26 16:34:12.000000000 +0100 @@ -0,0 +1,7 @@ +#if FOO + int x = 1; +#elsif BAR /* should be #elif */ + int x = 2; +#else + int x = 3; +#endif diff -Naur -x '*.info' gccintro-1.0/msg-nest1.h gccintro-1.1/msg-nest1.h --- gccintro-1.0/msg-nest1.h 1970-01-01 01:00:00.000000000 +0100 +++ gccintro-1.1/msg-nest1.h 2005-05-27 12:40:52.000000000 +0100 @@ -0,0 +1,3 @@ +/* foo.h */ +#include "bar.h" +... diff -Naur -x '*.info' gccintro-1.0/msg-nest2.h gccintro-1.1/msg-nest2.h --- gccintro-1.0/msg-nest2.h 1970-01-01 01:00:00.000000000 +0100 +++ gccintro-1.1/msg-nest2.h 2005-05-27 12:40:42.000000000 +0100 @@ -0,0 +1,3 @@ +/* bar.h */ +#include "foo.h" +... diff -Naur -x '*.info' gccintro-1.0/msg-null.c gccintro-1.1/msg-null.c --- gccintro-1.0/msg-null.c 1970-01-01 01:00:00.000000000 +0100 +++ gccintro-1.1/msg-null.c 2005-05-24 17:44:24.000000000 +0100 @@ -0,0 +1,8 @@ +#include + +int +main (void) +{ + int i = NULL; /* incorrect */ + return 0; +} diff -Naur -x '*.info' gccintro-1.0/msg-parse.c gccintro-1.1/msg-parse.c --- gccintro-1.0/msg-parse.c 1970-01-01 01:00:00.000000000 +0100 +++ gccintro-1.1/msg-parse.c 2005-05-24 17:39:19.000000000 +0100 @@ -0,0 +1,9 @@ +#include + +int +main (void) +{ + printf ("Hello ") /* missing semicolon */ + printf ("World!\n"); + return 0; +} diff -Naur -x '*.info' gccintro-1.0/msg-string2.c gccintro-1.1/msg-string2.c --- gccintro-1.0/msg-string2.c 1970-01-01 01:00:00.000000000 +0100 +++ gccintro-1.1/msg-string2.c 2005-05-24 17:41:24.000000000 +0100 @@ -0,0 +1,8 @@ +#include + +int +main (void) +{ + printf ('Hello World!\n'); /* wrong quotes */ + return 0; +} diff -Naur -x '*.info' gccintro-1.0/msg-string2.cc gccintro-1.1/msg-string2.cc --- gccintro-1.0/msg-string2.cc 1970-01-01 01:00:00.000000000 +0100 +++ gccintro-1.1/msg-string2.cc 2005-05-24 17:41:46.000000000 +0100 @@ -0,0 +1,8 @@ +#include + +int +main (void) +{ + std::cout << 'Hello World!\n'; // wrong quotes + return 0; +} diff -Naur -x '*.info' gccintro-1.0/msg-undeclared.c gccintro-1.1/msg-undeclared.c --- gccintro-1.0/msg-undeclared.c 1970-01-01 01:00:00.000000000 +0100 +++ gccintro-1.1/msg-undeclared.c 2005-05-24 17:39:01.000000000 +0100 @@ -0,0 +1,7 @@ +int +main (void) +{ + int i; + j = 0; /* undeclared */ + return j; +} diff -Naur -x '*.info' gccintro-1.0/msg-undef.c gccintro-1.1/msg-undef.c --- gccintro-1.0/msg-undef.c 1970-01-01 01:00:00.000000000 +0100 +++ gccintro-1.1/msg-undef.c 2005-05-23 12:01:12.000000000 +0100 @@ -0,0 +1,8 @@ +int foo(void); + +int +main (void) +{ + foo(); + return 0; +} diff -Naur -x '*.info' gccintro-1.0/msg-unknownesc.c gccintro-1.1/msg-unknownesc.c --- gccintro-1.0/msg-unknownesc.c 1970-01-01 01:00:00.000000000 +0100 +++ gccintro-1.1/msg-unknownesc.c 2005-04-20 16:29:02.000000000 +0100 @@ -0,0 +1,8 @@ +#include + +int +main (void) +{ + printf ("HELLO WORLD!\N"); + return 0; +} diff -Naur -x '*.info' gccintro-1.0/msg-unterm.c gccintro-1.1/msg-unterm.c --- gccintro-1.0/msg-unterm.c 1970-01-01 01:00:00.000000000 +0100 +++ gccintro-1.1/msg-unterm.c 2005-08-07 16:21:05.000000000 +0100 @@ -0,0 +1,8 @@ +#include + +int +main (void) +{ + printf ("Hello World!\n); /* no closing quote */ + return 0; +} diff -Naur -x '*.info' gccintro-1.0/msg-unused.c gccintro-1.1/msg-unused.c --- gccintro-1.0/msg-unused.c 1970-01-01 01:00:00.000000000 +0100 +++ gccintro-1.1/msg-unused.c 2005-05-11 12:22:26.000000000 +0100 @@ -0,0 +1,7 @@ +int +foo (int k, char * p) +{ + int i, j; + j = k; + return j; +} diff -Naur -x '*.info' gccintro-1.0/null.c gccintro-1.1/null.c --- gccintro-1.0/null.c 2004-01-28 12:47:58.000000000 +0000 +++ gccintro-1.1/null.c 2005-03-22 14:11:04.000000000 +0000 @@ -1,14 +1,14 @@ -int a (int *p); +int foo (int *p); int main (void) { int *p = 0; /* null pointer */ - return a (p); + return foo (p); } int -a (int *p) +foo (int *p) { int y = *p; return y; diff -Naur -x '*.info' gccintro-1.0/pi.c gccintro-1.1/pi.c --- gccintro-1.0/pi.c 2004-03-04 15:47:01.000000000 +0000 +++ gccintro-1.1/pi.c 2005-08-07 18:06:26.000000000 +0100 @@ -4,6 +4,6 @@ int main (void) { - printf("the value of pi is %f\n", M_PI); + printf ("the value of pi is %f\n", M_PI); return 0; } diff -Naur -x '*.info' gccintro-1.0/prof.c gccintro-1.1/prof.c --- gccintro-1.0/prof.c 2003-09-29 14:07:33.000000000 +0100 +++ gccintro-1.1/prof.c 1970-01-01 01:00:00.000000000 +0100 @@ -1,28 +0,0 @@ -#include - -double -f (int i) -{ - if (i == 1) - return i; - return i * f (i - 1); -} - -double -g (int i) -{ - double p = 1; - int k; - for (k = 1; k <= i; k++) - p *= k; - return p; -} - - -int -main (void) -{ - printf ("f(30) = %g\n", f (30)); - printf ("g(30) = %g\n", g (30)); - return 0; -} diff -Naur -x '*.info' gccintro-1.0/readdir.c gccintro-1.1/readdir.c --- gccintro-1.0/readdir.c 2004-03-04 15:05:24.000000000 +0000 +++ gccintro-1.1/readdir.c 1970-01-01 01:00:00.000000000 +0100 @@ -1,18 +0,0 @@ -#include -#include -#include - -int -main (void) -{ - DIR * d = opendir("."); - struct dirent * f; - - while ((f = readdir(d)) != 0) - { - printf("%s\n", f->d_name); - } - - return closedir(d); -} - diff -Naur -x '*.info' gccintro-1.0/rms.texi gccintro-1.1/rms.texi --- gccintro-1.0/rms.texi 2004-03-24 16:08:12.000000000 +0000 +++ gccintro-1.1/rms.texi 2004-08-23 14:08:35.000000000 +0100 @@ -27,7 +27,7 @@ without giving up our freedom. A compiler alone is not enough---to use a computer system, you need a -whole operating system. In 1983, all operating system for modern +whole operating system. In 1983, all operating systems for modern computers were non-free. To remedy this, in 1984 I began developing the GNU operating system, a Unix-like system that would be free software. Developing GCC was one part of developing GNU. diff -Naur -x '*.info' gccintro-1.0/setfpu.c gccintro-1.1/setfpu.c --- gccintro-1.0/setfpu.c 1970-01-01 01:00:00.000000000 +0100 +++ gccintro-1.1/setfpu.c 2005-04-01 17:30:38.000000000 +0100 @@ -0,0 +1,5 @@ +void +set_fpu (unsigned int mode) +{ + asm ("fldcw %0" : : "m" (*&mode)); +} diff -Naur -x '*.info' gccintro-1.0/signed.c gccintro-1.1/signed.c --- gccintro-1.0/signed.c 1970-01-01 01:00:00.000000000 +0100 +++ gccintro-1.1/signed.c 2005-08-07 18:06:25.000000000 +0100 @@ -0,0 +1,13 @@ +#include + +int +main (void) +{ + char c = 255; + if (c > 128) { + printf ("char is unsigned (c = %d)\n", c); + } else { + printf ("char is signed (c = %d)\n", c); + } + return 0; +} diff -Naur -x '*.info' gccintro-1.0/stl2.c gccintro-1.1/stl2.c --- gccintro-1.0/stl2.c 2003-10-13 10:42:29.000000000 +0100 +++ gccintro-1.1/stl2.c 1970-01-01 01:00:00.000000000 +0100 @@ -1,20 +0,0 @@ -#include -#include -#include - -using namespace std; - -void foo(); - -int -main () -{ - list list; - - list.push_front("Hello"); - list.push_back("World"); - - cout << "List size = " << list.size() << endl; - foo(); - return 0; -} diff -Naur -x '*.info' gccintro-1.0/stl3.c gccintro-1.1/stl3.c --- gccintro-1.0/stl3.c 2003-10-13 10:42:41.000000000 +0100 +++ gccintro-1.1/stl3.c 1970-01-01 01:00:00.000000000 +0100 @@ -1,15 +0,0 @@ -#include -#include -#include - -using namespace std; - -void foo(void) -{ - list list; - - list.push_front("Hello"); - list.push_back("World"); - - cout << "List size = " << list.size() << endl; -} diff -Naur -x '*.info' gccintro-1.0/string.cc gccintro-1.1/string.cc --- gccintro-1.0/string.cc 2003-10-13 13:33:01.000000000 +0100 +++ gccintro-1.1/string.cc 2004-07-13 11:45:52.000000000 +0100 @@ -10,6 +10,6 @@ list list; list.push_back("Hello"); list.push_back("World"); - cout << "List size = " << list.size() << endl; + cout << "List size = " << list.size() << '\n'; return 0; } diff -Naur -x '*.info' gccintro-1.0/sus.c gccintro-1.1/sus.c --- gccintro-1.0/sus.c 2003-09-12 21:22:01.000000000 +0100 +++ gccintro-1.1/sus.c 1970-01-01 01:00:00.000000000 +0100 @@ -1,4 +0,0 @@ -int foo(unsigned int i) -{ - return (i < 12345678901); -} diff -Naur -x '*.info' gccintro-1.0/testgetc2.c gccintro-1.1/testgetc2.c --- gccintro-1.0/testgetc2.c 1970-01-01 01:00:00.000000000 +0100 +++ gccintro-1.1/testgetc2.c 2005-07-20 16:44:15.000000000 +0100 @@ -0,0 +1,13 @@ +#include + +int +main (void) +{ + int i; + while ((i = getchar()) != EOF) + { + unsigned char c = i; + printf ("read c = '%c'\n", c); + } + return 0; +} diff -Naur -x '*.info' gccintro-1.0/testgetc.c gccintro-1.1/testgetc.c --- gccintro-1.0/testgetc.c 1970-01-01 01:00:00.000000000 +0100 +++ gccintro-1.1/testgetc.c 2005-07-20 16:43:51.000000000 +0100 @@ -0,0 +1,12 @@ +#include + +int +main (void) +{ + char c; + while ((c = getchar()) != EOF) /* not portable */ + { + printf ("read c = '%c'\n", c); + } + return 0; +} diff -Naur -x '*.info' gccintro-1.0/tmain.cc gccintro-1.1/tmain.cc --- gccintro-1.0/tmain.cc 2003-10-18 16:59:43.000000000 +0100 +++ gccintro-1.1/tmain.cc 1970-01-01 01:00:00.000000000 +0100 @@ -1,15 +0,0 @@ -#include -#include "buffer.h" -#include "tprint.h" - -using namespace std; - -int -main () -{ - Buffer f(10); - f.insert (0.23); - f.insert (1.0 + f.get()); - print (f); - return 0; -} diff -Naur -x '*.info' gccintro-1.0/tmp.cc gccintro-1.1/tmp.cc --- gccintro-1.0/tmp.cc 2004-03-17 16:14:07.000000000 +0000 +++ gccintro-1.1/tmp.cc 1970-01-01 01:00:00.000000000 +0100 @@ -1,15 +0,0 @@ -#include -#include "buffer.h" - -using namespace std; - -int -main () -{ - Buffer f(10); - f.insert (0.25); - f.insert (1.0 + f.get(0)); - cout << "stored value 0 = " << f.get(0) << endl; - cout << "stored value 1 = " << f.get(1) << endl; - return 0; -} diff -Naur -x '*.info' gccintro-1.0/tprint.cc gccintro-1.1/tprint.cc --- gccintro-1.0/tprint.cc 2003-10-18 17:00:55.000000000 +0100 +++ gccintro-1.1/tprint.cc 1970-01-01 01:00:00.000000000 +0100 @@ -1,11 +0,0 @@ -#include -#include "buffer.h" -#include "tprint.h" - -using namespace std; - -void -print (Buffer buff) -{ - cout << "stored value = " << buff.get() << endl; -} diff -Naur -x '*.info' gccintro-1.0/tprint.h gccintro-1.1/tprint.h --- gccintro-1.0/tprint.h 2003-10-18 16:59:54.000000000 +0100 +++ gccintro-1.1/tprint.h 1970-01-01 01:00:00.000000000 +0100 @@ -1 +0,0 @@ -void print (Buffer buff); diff -Naur -x '*.info' gccintro-1.0/tprog.cc gccintro-1.1/tprog.cc --- gccintro-1.0/tprog.cc 2004-01-30 11:29:34.000000000 +0000 +++ gccintro-1.1/tprog.cc 2004-07-13 11:46:33.000000000 +0100 @@ -9,6 +9,6 @@ Buffer f(10); f.insert (0.25); f.insert (1.0 + f.get(0)); - cout << "stored value = " << f.get(0) << endl; + cout << "stored value = " << f.get(0) << '\n'; return 0; } diff -Naur -x '*.info' gccintro-1.0/uninit2.c gccintro-1.1/uninit2.c --- gccintro-1.0/uninit2.c 2003-09-20 15:44:50.000000000 +0100 +++ gccintro-1.1/uninit2.c 1970-01-01 01:00:00.000000000 +0100 @@ -1,8 +0,0 @@ -#include - -int -main (void) -{ - double x; - printf("x=%g\n", x); -} diff -Naur -x '*.info' gccintro-1.0/wabs.c gccintro-1.1/wabs.c --- gccintro-1.0/wabs.c 1970-01-01 01:00:00.000000000 +0100 +++ gccintro-1.1/wabs.c 2005-08-07 16:21:24.000000000 +0100 @@ -0,0 +1,11 @@ +#include +#include + +int +main (void) +{ + double x = -3.14; + double y = abs(x); /* should be fabs(x) */ + printf ("x = %g |x| = %g\n", x, y); + return 0; +} diff -Naur -x '*.info' gccintro-1.0/whetstone.c gccintro-1.1/whetstone.c --- gccintro-1.0/whetstone.c 1998-03-22 20:02:28.000000000 +0000 +++ gccintro-1.1/whetstone.c 1970-01-01 01:00:00.000000000 +0100 @@ -1,433 +0,0 @@ -/* - * C Converted Whetstone Double Precision Benchmark - * Version 1.2 22 March 1998 - * - * (c) Copyright 1998 Painter Engineering, Inc. - * All Rights Reserved. - * - * Permission is granted to use, duplicate, and - * publish this text and program as long as it - * includes this entire comment block and limited - * rights reference. - * - * Converted by Rich Painter, Painter Engineering, Inc. based on the - * www.netlib.org benchmark/whetstoned version obtained 16 March 1998. - * - * A novel approach was used here to keep the look and feel of the - * FORTRAN version. Altering the FORTRAN-based array indices, - * starting at element 1, to start at element 0 for C, would require - * numerous changes, including decrementing the variable indices by 1. - * Instead, the array E1[] was declared 1 element larger in C. This - * allows the FORTRAN index range to function without any literal or - * variable indices changes. The array element E1[0] is simply never - * used and does not alter the benchmark results. - * - * The major FORTRAN comment blocks were retained to minimize - * differences between versions. Modules N5 and N12, like in the - * FORTRAN version, have been eliminated here. - * - * An optional command-line argument has been provided [-c] to - * offer continuous repetition of the entire benchmark. - * An optional argument for setting an alternate LOOP count is also - * provided. Define PRINTOUT to cause the POUT() function to print - * outputs at various stages. Final timing measurements should be - * made with the PRINTOUT undefined. - * - * Questions and comments may be directed to the author at - * r.painter@ieee.org - */ -/* -C********************************************************************** -C Benchmark #2 -- Double Precision Whetstone (A001) -C -C o This is a REAL*8 version of -C the Whetstone benchmark program. -C -C o DO-loop semantics are ANSI-66 compatible. -C -C o Final measurements are to be made with all -C WRITE statements and FORMAT sttements removed. -C -C********************************************************************** -*/ - -/* standard C library headers required */ -#include -#include -#include -#include - -/* the following is optional depending on the timing function used */ -#include - -/* map the FORTRAN math functions, etc. to the C versions */ -#define DSIN sin -#define DCOS cos -#define DATAN atan -#define DLOG log -#define DEXP exp -#define DSQRT sqrt -#define IF if - -/* function prototypes */ -void POUT(long N, long J, long K, double X1, double X2, double X3, double X4); -void PA(double E[]); -void P0(void); -void P3(double X, double Y, double *Z); -#define USAGE "usage: whetdc [-c] [loops]\n" - -/* - COMMON T,T1,T2,E1(4),J,K,L -*/ -double T,T1,T2,E1[5]; -int J,K,L; - -int -main(int argc, char *argv[]) -{ - /* used in the FORTRAN version */ - long I; - long N1, N2, N3, N4, N6, N7, N8, N9, N10, N11; - double X1,X2,X3,X4,X,Y,Z; - long LOOP; - int II, JJ; - - /* added for this version */ - long loopstart; - long startsec, finisec; - float KIPS; - int continuous; - - loopstart = 1000; /* see the note about LOOP below */ - continuous = 0; - - II = 1; /* start at the first arg (temp use of II here) */ - while (II < argc) { - if (strncmp(argv[II], "-c", 2) == 0 || argv[II][0] == 'c') { - continuous = 1; - } else if (atol(argv[II]) > 0) { - loopstart = atol(argv[II]); - } else { - fprintf(stderr, USAGE); - return(1); - } - II++; - } - -LCONT: -/* -C -C Start benchmark timing at this point. -C -*/ - startsec = time(0); - -/* -C -C The actual benchmark starts here. -C -*/ - T = .499975; - T1 = 0.50025; - T2 = 2.0; -/* -C -C With loopcount LOOP=10, one million Whetstone instructions -C will be executed in EACH MAJOR LOOP..A MAJOR LOOP IS EXECUTED -C 'II' TIMES TO INCREASE WALL-CLOCK TIMING ACCURACY. -C - LOOP = 1000; -*/ - LOOP = loopstart; - II = 1; - - JJ = 1; - -IILOOP: - N1 = 0; - N2 = 12 * LOOP; - N3 = 14 * LOOP; - N4 = 345 * LOOP; - N6 = 210 * LOOP; - N7 = 32 * LOOP; - N8 = 899 * LOOP; - N9 = 616 * LOOP; - N10 = 0; - N11 = 93 * LOOP; -/* -C -C Module 1: Simple identifiers -C -*/ - X1 = 1.0; - X2 = -1.0; - X3 = -1.0; - X4 = -1.0; - - for (I = 1; I <= N1; I++) { - X1 = (X1 + X2 + X3 - X4) * T; - X2 = (X1 + X2 - X3 + X4) * T; - X3 = (X1 - X2 + X3 + X4) * T; - X4 = (-X1+ X2 + X3 + X4) * T; - } -#ifdef PRINTOUT - IF (JJ==II)POUT(N1,N1,N1,X1,X2,X3,X4); -#endif - -/* -C -C Module 2: Array elements -C -*/ - E1[1] = 1.0; - E1[2] = -1.0; - E1[3] = -1.0; - E1[4] = -1.0; - - for (I = 1; I <= N2; I++) { - E1[1] = ( E1[1] + E1[2] + E1[3] - E1[4]) * T; - E1[2] = ( E1[1] + E1[2] - E1[3] + E1[4]) * T; - E1[3] = ( E1[1] - E1[2] + E1[3] + E1[4]) * T; - E1[4] = (-E1[1] + E1[2] + E1[3] + E1[4]) * T; - } - -#ifdef PRINTOUT - IF (JJ==II)POUT(N2,N3,N2,E1[1],E1[2],E1[3],E1[4]); -#endif - -/* -C -C Module 3: Array as parameter -C -*/ - for (I = 1; I <= N3; I++) - PA(E1); - -#ifdef PRINTOUT - IF (JJ==II)POUT(N3,N2,N2,E1[1],E1[2],E1[3],E1[4]); -#endif - -/* -C -C Module 4: Conditional jumps -C -*/ - J = 1; - for (I = 1; I <= N4; I++) { - if (J == 1) - J = 2; - else - J = 3; - - if (J > 2) - J = 0; - else - J = 1; - - if (J < 1) - J = 1; - else - J = 0; - } - -#ifdef PRINTOUT - IF (JJ==II)POUT(N4,J,J,X1,X2,X3,X4); -#endif - -/* -C -C Module 5: Omitted -C Module 6: Integer arithmetic -C -*/ - - J = 1; - K = 2; - L = 3; - - for (I = 1; I <= N6; I++) { - J = J * (K-J) * (L-K); - K = L * K - (L-J) * K; - L = (L-K) * (K+J); - E1[L-1] = J + K + L; - E1[K-1] = J * K * L; - } - -#ifdef PRINTOUT - IF (JJ==II)POUT(N6,J,K,E1[1],E1[2],E1[3],E1[4]); -#endif - -/* -C -C Module 7: Trigonometric functions -C -*/ - X = 0.5; - Y = 0.5; - - for (I = 1; I <= N7; I++) { - X = T * DATAN(T2*DSIN(X)*DCOS(X)/(DCOS(X+Y)+DCOS(X-Y)-1.0)); - Y = T * DATAN(T2*DSIN(Y)*DCOS(Y)/(DCOS(X+Y)+DCOS(X-Y)-1.0)); - } - -#ifdef PRINTOUT - IF (JJ==II)POUT(N7,J,K,X,X,Y,Y); -#endif - -/* -C -C Module 8: Procedure calls -C -*/ - X = 1.0; - Y = 1.0; - Z = 1.0; - - for (I = 1; I <= N8; I++) - P3(X,Y,&Z); - -#ifdef PRINTOUT - IF (JJ==II)POUT(N8,J,K,X,Y,Z,Z); -#endif - -/* -C -C Module 9: Array references -C -*/ - J = 1; - K = 2; - L = 3; - E1[1] = 1.0; - E1[2] = 2.0; - E1[3] = 3.0; - - for (I = 1; I <= N9; I++) - P0(); - -#ifdef PRINTOUT - IF (JJ==II)POUT(N9,J,K,E1[1],E1[2],E1[3],E1[4]); -#endif - -/* -C -C Module 10: Integer arithmetic -C -*/ - J = 2; - K = 3; - - for (I = 1; I <= N10; I++) { - J = J + K; - K = J + K; - J = K - J; - K = K - J - J; - } - -#ifdef PRINTOUT - IF (JJ==II)POUT(N10,J,K,X1,X2,X3,X4); -#endif - -/* -C -C Module 11: Standard functions -C -*/ - X = 0.75; - - for (I = 1; I <= N11; I++) - X = DSQRT(DEXP(DLOG(X)/T1)); - -#ifdef PRINTOUT - IF (JJ==II)POUT(N11,J,K,X,X,X,X); -#endif - -/* -C -C THIS IS THE END OF THE MAJOR LOOP. -C -*/ - if (++JJ <= II) - goto IILOOP; - -/* -C -C Stop benchmark timing at this point. -C -*/ - finisec = time(0); - -/* -C---------------------------------------------------------------- -C Performance in Whetstone KIP's per second is given by -C -C (100*LOOP*II)/TIME -C -C where TIME is in seconds. -C-------------------------------------------------------------------- -*/ - printf("\n"); - if (finisec-startsec <= 0) { - printf("Insufficient duration- Increase the LOOP count\n"); - return(1); - } - - printf("Loops: %ld, Iterations: %d, Duration: %ld sec.\n", - LOOP, II, finisec-startsec); - - KIPS = (100.0*LOOP*II)/(float)(finisec-startsec); - if (KIPS >= 1000.0) - printf("C Converted Double Precision Whetstones: %.1f MIPS\n", KIPS/1000.0); - else - printf("C Converted Double Precision Whetstones: %.1f KIPS\n", KIPS); - - if (continuous) - goto LCONT; - - return(0); -} - -void -PA(double E[]) -{ - J = 0; - -L10: - E[1] = ( E[1] + E[2] + E[3] - E[4]) * T; - E[2] = ( E[1] + E[2] - E[3] + E[4]) * T; - E[3] = ( E[1] - E[2] + E[3] + E[4]) * T; - E[4] = (-E[1] + E[2] + E[3] + E[4]) / T2; - J += 1; - - if (J < 6) - goto L10; -} - -void -P0(void) -{ - E1[J] = E1[K]; - E1[K] = E1[L]; - E1[L] = E1[J]; -} - -void -P3(double X, double Y, double *Z) -{ - double X1, Y1; - - X1 = X; - Y1 = Y; - X1 = T * (X1 + Y1); - Y1 = T * (X1 + Y1); - *Z = (X1 + Y1) / T2; -} - -#ifdef PRINTOUT -void -POUT(long N, long J, long K, double X1, double X2, double X3, double X4) -{ - printf("%7ld %7ld %7ld %12.4e %12.4e %12.4e %12.4e\n", - N, J, K, X1, X2, X3, X4); -} -#endif debian/patches/0002-Update-contents-for-Debian.patch0000644000000000000000000003472412013675337017257 0ustar From 306e2fd31d176bc0840321a1286a7ca2a5cf3d62 Mon Sep 17 00:00:00 2001 From: Osamu Aoki Date: Sat, 14 Jul 2012 01:58:12 +0900 Subject: [PATCH 2/3] Update contents for Debian gccintro.texi Add security options (bof.c, format.c) Add multiarch --- bof.c | 23 ++++++ format.c | 19 +++++ gccintro.texi | 248 ++++++++++++++++++++++++++++++++++++++++++++++++++++----- 3 files changed, 268 insertions(+), 22 deletions(-) create mode 100644 bof.c create mode 100644 format.c diff --git a/bof.c b/bof.c new file mode 100644 index 0000000..61e51a2 --- /dev/null +++ b/bof.c @@ -0,0 +1,23 @@ +#include +#include +#include + +#define DESTLEN 8 +int main(int argc, char** argv) +{ + char dest[DESTLEN]; + if (argc == 2) + { + printf(">>> Before the possible buffer over flow >>>\n"); + strcpy(dest, argv[1]); + printf("<<< After the possible buffer over flow <<<\n"); + } + else + { + fprintf(stderr,"Usage: %s ARG\n", argv[0]); + fprintf(stderr," Character length(ARG) < %i bytes\n", DESTLEN); + exit(1); + } + return 0; +} + diff --git a/format.c b/format.c new file mode 100644 index 0000000..985ece2 --- /dev/null +++ b/format.c @@ -0,0 +1,19 @@ +#include +#include +#include + +int main(int argc, char** argv) +{ + if (argc == 2) + { + fprintf(stderr, argv[1]); + fprintf(stderr, "\n"); + } + else + { + fprintf(stderr,"Usage: %s ARG\n", argv[0]); + exit(1); + } + return 0; +} + diff --git a/gccintro.texi b/gccintro.texi index bfa0a60..4148e38 100644 --- a/gccintro.texi +++ b/gccintro.texi @@ -103,6 +103,7 @@ published by Network Theory Ltd raise money for more free documentation. * Compiling for debugging:: * Compiling with optimization:: * Compiling a C++ program:: +* Security enhancement options:: * Platform-specific options:: * Troubleshooting:: * Compiler-related tools:: @@ -927,11 +928,14 @@ chapter. @cindex standard library, C @cindex library, C standard library The standard system libraries are usually found in the directories -@file{/usr/lib} and @file{/lib}.@footnote{On systems supporting both 64 -and 32-bit executables the 64-bit versions of the libraries will often -be stored in @file{/usr/lib64} and @file{/lib64}, with the 32-bit -versions in @file{/usr/lib} and @file{/lib}.} For example, the C math -library is typically stored in the file @file{/usr/lib/libm.a} on Unix-like +@file{/usr/lib} and @file{/lib}.@footnote{On systems supporting both 64 and +32-bit executables, their libraries are stored in the directories +@file{/lib/x86_64-linux-gnu} and @file{/usr/lib/x86_64-linux-gnu}, or +@file{/lib64} and @file{/usr/lib64} for 64-bit libraries; and +@file{/lib/i386-linux-gnu} and @file{/usr/lib/i386-linux-gnu}, or @file{/lib} +and @file{/usr/lib} for 32-bit libraries, instead. @pxref{Multi-architecture +support}} For example, the C math +library is typically stored in the file @file{/usr/lib/libm.so} on Unix-like systems. The corresponding prototype declarations for the functions in this library are given in the header file @file{/usr/include/math.h}. The C standard library itself is stored in @file{/usr/lib/libc.a} and @@ -1237,12 +1241,13 @@ The list of directories for header files is often referred to as the @cindex libraries, on 64-bit platforms @cindex 64-bit platforms, additional library directories @cindex system libraries, location of -The directories on these paths are searched in order, from first to last -in the two lists above.@footnote{The default search paths may also -include additional system-dependent or site-specific directories, and -directories in the GCC installation itself. For example, on 64-bit -platforms additional @file{lib64} directories may also be searched by -default.} For example, a header file found in +The directories on these paths are searched in order, from first to last in +the two lists above.@footnote{The default search paths may also include +additional system-dependent or site-specific directories, and directories in +the GCC installation itself. For example, on 64-bit platforms additional +@file{/usr/lib/x86_64-linux-gnu} or @file{/usr/lib64} directories may also be +searched by default. @pxref{Multi-architecture support}} +For example, a header file found in @file{/usr/local/include} takes precedence over a file with the same name in @file{/usr/include}. Similarly, a library found in @file{/usr/local/lib} takes precedence over a library with the same @@ -3867,7 +3872,192 @@ do not support it either. The inclusion compilation model described earlier is recommended as the simplest and most portable way to use templates. +@node Security enhancement options +@chapter Security enhancement options +@cindex security enhancement options +@cindex options, security enhancement +Recent GCC (4.1 or newer) on modern hardwares provides a good range of +security enhancement options. Popular security enhancement options used by +the major Linux distributions for their package building defaults and some +non-default options are described here.@footnote{For Debian wheezy, you can +obtain distribution recommended GCC options using the @code{dpkg-buildflag} +command.} You should consider enabling these options for your application as +needed by explicitly specifying them. + +Please note that these security enhancement options may not be available on +your platform. + +Please also note that these security enhancement options may cause problems +depending on your GCC version and your application. Since some distributions +make these options as the default of GCC, you may need to explicitly disable +these options for some limited situations to avoid such problems. + +@menu +* Warning for format string:: +* Stack smashing protector (SSP):: +* Buffer overflow protection:: +* Read-only relocations:: +* Binding policy NOW:: +@end menu + +@node Warning for format string +@section Warning for format string +@cindex warning for format string +@cindex @option{-Wformat-security} option, warn about uncontrolled format string +@cindex @option{-Wformat} option, warn about incorrect format strings +@cindex uncontrolled format string +The possible security vulnerability of uncontrolled format +string@footnote{@uref{http://en.wikipedia.org/wiki/Uncontrolled_format_string}} +in @code{printf()} and the similar functions can be detected and warned with GCC using the +option @option{-Wformat -Wformat-security}. + +Example of insecure code: @file{format.c} + +@example +@verbatiminclude format.c +@end example +@noindent + +The insecure program @file{format.c} can be compiled without obvious warnings. + +@example +$ gcc -Wall format.c +@end example +@noindent + +The insecure program @file{format.c} can be compiled with the option +@option{-Wformat -Wformat-security} with warnings. + +@example +$ gcc -Wformat -Wformat-security format.c +format.c: In function ‘main’: +format.c:9:7: warning: format not a string literal and no format arguments +[-Wformat-security] +@end example +@noindent + +The output shows that the @file{format.c} program compiled with the option +@option{-Wformat-security} warns about the possible security vulnerability of +uncontrolled format string. + +@node Stack smashing protector (SSP) +@section Stack smashing protector (SSP) +@cindex stack smashing protector +@cindex SSP, stack smashing protector +@cindex @option{-fstack-protector} option +@cindex @option{--param=ssp-buffer-size=4} option +Exploitability of many buffer +overflows@footnote{@uref{http://en.wikipedia.org/wiki/Buffer_overflow_protection}} +can be mitigated by compiling a program with GCC using the option +@option{-fstack-protector}.@footnote{You may use the option +@option{-fstack-protector --param=ssp-buffer-size=4} instead to protect more +functions with SSP. See @file{/usr/share/doc/gcc-*/README.ssp}.} + +This option causes the GCC to insert a check for stack buffer overflows before +function returns. If an attempt is made to exploit a buffer overflow +vulnerability in the program, the application will be killed immediately. This +reduces the risk of any unknown potential exploits to a denial-of-service. + +Example of insecure code: @file{bof.c} + +@example +@verbatiminclude bof.c +@end example +@noindent + +The insecure program @file{bof.c} can be compiled without obvious warnings. + +@example +$ gcc -Wall bof.c -o bof +$ ./bof '123456789' || echo error +>>> Before the possible buffer over flow >>> +<<< After the possible buffer over flow <<< +@end example +@noindent + +The output shows that the @file{bof.c} program compiled without using +the option @option{-fstack-protector} creates an executable @file{bof} which +executes an insecure buffer overflow code silently. + +The insecure program @file{bof.c} can be compiled with the option +@option{-fstack-protector}. + +@example +$ gcc -Wall -fstack-protector bof.c -o bof-ssp +$ ./bof-ssp '123456789' || echo error +>>> Before the possible buffer over flow >>> +<<< After the possible buffer over flow <<< +*** stack smashing detected ***: ./bof-ssp terminated +... [snipped] +Aborted +Error +@end example +@noindent + +The output shows that the @file{bof.c} program compiled with the option +@option{-fstack-protector} creates an executable @file{bof-ssp}. When the +executable @file{bof-ssp} is executed, it detects stack smashing and exits safely. + +@node Buffer overflow protection +@section Buffer overflow protection +@cindex buffer overflow protection +@cindex @option{-D_FORTIFY_SOURCE} option +@cindex @option{-O1} option, optimization level one +@cindex @option{-O2} option, optimization level two +@cindex @code{_FORTIFY_SOURCE} macro +The GCC macro definition of @option{-D_FORTIFY_SOURCE} provides a lightweight +buffer overflow protection to some memory and string functions provided by the +GLIBC. This feature uses macro substitution of such vulnerable functions to +prevent an insecure buffer overflow code to be executed. The compiler +optimization option needs to be @option{-O1} or higher to enable +@option{-D_FORTIFY_SOURCE}.@footnote{@uref{http://www.redhat.com/archives/fedora-tools-list/2004-September/msg00002.html}} + +The insecure program @file{bof.c} shown in the previous section can be compiled +with the option @option{-D_FORTIFY_SOURCE=2 -O2}. + +@example +$ gcc -Wall -D_FORTIFY_SOURCE=2 -O2 bof.c -o bof-fort +$ ./bof-fort '123456789' || echo error +>>> Before the possible buffer over flow >>> +*** buffer overflow detected ***: ./bof-fort terminated +... [snipped] +Aborted +Error +@end example +@noindent + +The output shows that the @file{bof.c} program compiled with the option +@option{-D_FORTIFY_SOURCE=2 -O2} creates an executable @file{bof-fort} which +stops before executing an insecure buffer overflow code. + +This @option{-D_FORTIFY_SOURCE} option is a quick fix for older programs +written with fixed length buffers. But if you are writing a software program +from scratch, please consider to use the secure libraries such as the +@code{GLib} library@footnote{@uref{http://en.wikipedia.org/wiki/GLib}} instead +of the standard @code{Libc} library. + +@node Read-only relocations +@section Read-only relocations +@cindex Read-only relocations +@cindex @option{-Wl,z,relro} option +The GCC linker option of @option{-Wl,z,relro} for the read-only relocations provides +read-only protection to several ELF memory sections after the program is loaded +and linked completely by the linker to prevent attacks that involve overwriting +data in the Global Offset Table (GOT). + +@node Binding policy NOW +@section Binding policy NOW +@cindex Binding policy NOW +@cindex @option{-Wl,z,now} option +@cindex @option{-Wl,z,relro} option +The GCC optional linker option of @option{-Wl,z,now} for the binding policy NOW +forces the program to load and link completely and marks its GOT read-only with +the @option{-Wl,z,relro} option before turning over control to the program. + +Since this option causes start-up slowdown for large applications, this is not +enabled by default. But this option may be interesting for the security +conscious network daemons. @node Platform-specific options @chapter Platform-specific options @@ -4199,19 +4389,33 @@ files, but giving the @option{-m32} option will generate a 32-bit object file for the corresponding architecture.@footnote{The options @option{-maix64} and @option{-maix32} are used on AIX.} -@cindex Itanium, multi-architecture support @cindex system libraries, location of Note that support for multiple architectures depends on the -corresponding libraries being available. On 64-bit platforms supporting -both 64 and 32-bit executables, the 64-bit libraries are often placed in -@file{lib64} directories instead of @file{lib} directories, e.g. in -@file{/usr/lib64} and @file{/lib64}. The 32-bit libraries are then -found in the default @file{lib} directories as on other platforms. This -allows both a 32-bit and a 64-bit library with the same name to exist on -the same system. Other systems, such as the IA64/Itanium, use the -directories @file{/usr/lib} and @file{/lib} for 64-bit libraries. GCC -knows about these paths and uses the appropriate path when compiling -64-bit or 32-bit code. +corresponding libraries being available. GCC knows about these paths +and uses the appropriate path when compiling 64-bit or 32-bit code. + +@cindex multi-architecture support, Debian +@cindex multi-architecture support, Ubuntu +On systems simultaneously supporting multiple binary target +architectures such as Debian wheezy and Ubuntu 11.04, the libraries with +the corresponding architecture ABI will be stored in +@file{/usr/lib/@var{multiarch_name}} and +@file{/lib/@var{multiarch_name}}. The multiarch architecture specifier +(tuple) @file{@var{multiarch_name}} takes values such as +@file{x86_64-linux-gnu} for the 64-bit PC Linux versions, and +@file{i386-linux-gnu} for the 32-bit PC Linux versions. Please note +that the multiarch architecture specifier is not exactly the same as the +GNU triplets although they are similar. + +@cindex multi-architecture support, RedHat +@cindex multi-architecture support, older systems +@cindex Itanium, multi-architecture support +On most system simultaneously supporting only 32-bit and 64-bit binary +target architectures such as RedHat, the 64-bit versions of the +libraries will often be stored in @file{/usr/lib64} and @file{/lib64}, +with the 32-bit versions in @file{/usr/lib} and @file{/lib}. Other +systems, such as the IA64/Itanium, use the directories @file{/usr/lib} +and @file{/lib} for 64-bit libraries. @node Floating-point issues @section Floating-point issues -- 1.7.10.4 debian/patches/0003-Update-title-etc.-for-Debian.patch0000644000000000000000000000374512013675337017372 0ustar From f761be5e2075b87d01e54a2a42ccc451522d7565 Mon Sep 17 00:00:00 2001 From: Osamu Aoki Date: Sun, 15 Jul 2012 14:18:43 +0900 Subject: [PATCH 3/3] Update title etc. for Debian gccintro.text No @ifset publish Add comment of Debian adjustment to the original --- gccintro.texi | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/gccintro.texi b/gccintro.texi index 4148e38..2036470 100644 --- a/gccintro.texi +++ b/gccintro.texi @@ -25,13 +25,19 @@ @titlepage @title An Introduction to GCC @subtitle for the GNU Compilers @code{gcc} and @code{g++} -@subtitle Revised and updated +@subtitle Revised and updated for Debian @author Brian Gough @author Foreword by Richard M.@: Stallman @page +Debian package version. 2012 + +The content of this Debian packaged version adds a chapter on ``Security +enhancement options'' and makes some minor file path adjustments to match +learning experiences under the Debian environment. @vskip 0pt plus 1filll -@ifset publish @flushleft +Followings are the original page content. + A catalogue record for this book is available from the British Library. Second printing, August 2005 (1/8/2005). Revised and updated. @@ -61,7 +67,6 @@ of Static Free Software Free Software provides support for Electric to the electronics design industry. @vskip 1ex -@end ifset Copyright @copyright{} 2004, 2005 Network Theory Ltd. Permission is granted to copy, distribute and/or modify this document @@ -93,6 +98,10 @@ This manual provides an introduction to the GNU C and C++ Compilers, The development of this manual was funded entirely by @uref{http://www.network-theory.co.uk/,Network Theory Ltd}. Copies published by Network Theory Ltd raise money for more free documentation. + +The content of this Debian packaged version adds a chapter on ``Security +enhancement options'' and makes some minor file path adjustments to match +learning experiences under the Debian environment. @end ifnottex @menu -- 1.7.10.4 debian/doc-base0000644000000000000000000000134212013675421010567 0ustar Document: gccintro Title: Introduction to GCC by Brian J. Gough Author: Brian J. Gough Abstract: This manual provides a tutorial introduction to the GNU C and C++ compilers, gcc and g++. . Many books teach the C and C++ languages, this book explains how to use the compiler itself. Based on years of observation of questions posted on mailing lists, it guides the reader straight to the important options of GCC! Section: Programming/C Format: PDF Files: /usr/share/doc/gccintro/gccintro.pdf.gz Format: HTML Index: /usr/share/doc/gccintro/gccintro/index.html Files: /usr/share/doc/gccintro/gccintro/*.html Format: Info Index: /usr/share/info/gccintro.info.gz Files: /usr/share/info/gccintro.info*.gz