> 
> Unless I compile with -Wall, following code compiles with no warning
> with "gcc -g -o example example.c".
> 
> How should I tell that this code is broke after compile?
> ----------
> # include <stdio.h>
> /*# include <stdlib.h>*/ /*Not to have this for atof is the bug*/
> int main(int argc, char **argv) {
> float x=0;
> x=atof("123.456");
> printf("%8.4f\n",x);
> return 0;
> }
> ----------------
> $ ./example
> 1078984704.0000
> $
> ----------------

If you can't use -Wall you might try lint.  There is a lint package
called "lclint".  "lint noproto.c" (your example code) produces this:

LCLint 2.4b --- 18 Apr 98

noproto.c: (in function main)
noproto.c:5:1: Assignment of double to float: x = atof("123.456")
  Types are incompatible. (-type will suppress message)
noproto.c:3:14: Parameter argc not used
  A function parameter is not used in the body of the function. If the
argument
  is needed for type compatibility or future plans, use /[EMAIL PROTECTED]@*/ 
in the
  argument declaration. (-paramuse will suppress message)
noproto.c:3:27: Parameter argv not used

Finished LCLint checking --- 3 code errors found

hth
jim

Reply via email to