[Subject Prev][Subject Next][Thread Prev][Thread Next][Subject Index][Thread Index]

Re: compiling

Ð ë ê þ ã K wrote (deepak2000@xxxxxxxxxxxx):

> i tried compiling  a c program as
> cc myprog.c 

This is slightly unrelated, but still worth knowing.

_Never_ compile you program without including any warning flags.
"cc foo.c" or "gcc foo.c" will silently compile nearly anything you throw at

Here is a simple replacement... this script is named "gnuc" and you use it by
doing "gnuc foo.c" instead of "gcc foo.c". Note that this scripts puts gcc in
ansi compilant mode (and paranoid warning level:) and is very restrictive. It
also enables debugging properly (-g -00; try stepping through optimized code
and you will realise) (this also relates to some previous posts).

This script is a real overkill, and may even refuse to compile some
legitimate C progs (it is primarily used to compile 1st yr under grad
projects). Do not compile production code with this, only debugging code.
Use wisely!

- Raja
PS: Appologies for a possible double post... I think I stuffed up my first
post (bugger).

<<<<<<<cut here>>>>>>>

# File: gnuc
# This runs gcc with all warnings enabled, except for the following
# exceptions:
# -Wredundant-decls	causes too many complaints in system header files
# -Wconversion		really only intended to help people using `unprotoize'
# -Waggregate-return	not useful, IMHO
# -Wenum-clash 		doesn't work with gcc 2.7.x
# fjh, Tue Oct 29 1996

OPTS="-ansi -pedantic -D_LONGLONG
      -Wall -Wwrite-strings -Wid-clash-31 -Wpointer-arith -Wcast-qual
      -Wcast-align -Wtraditional
      -Wstrict-prototypes -Wmissing-prototypes
      -Wnested-externs -Wshadow
      -Woverloaded-virtual -Winline
      -O -felide-constructors -fnonnull-objects

exec gcc $OPTS "$@"
<<<<<<<cut here>>>>>>>