home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / std / c / 3270 < prev    next >
Encoding:
Text File  |  1992-12-24  |  1.7 KB  |  54 lines

  1. Newsgroups: comp.std.c
  2. Path: sparky!uunet!gatech!udel!wupost!micro-heart-of-gold.mit.edu!xn.ll.mit.edu!ll.mit.edu!tadams
  3. From: tadams@ll.mit.edu ( Tony Adams)
  4. Subject: Mixing prototype and non-prototype issues
  5. Message-ID: <1992Dec24.234622.29882@ll.mit.edu>
  6. Originator: tadams@ll.mit.edu ( Tony Adams)
  7. Sender: news@ll.mit.edu
  8. Organization: MIT Lincoln Laboratory
  9. Date: Thu, 24 Dec 92 23:46:22 GMT
  10. Lines: 42
  11.  
  12.  
  13. The following script shows an example of a function call which is not
  14. governed by a prototype, calling a (non-visible) function defined in
  15. prototype syntax.
  16.  
  17. Would someone please report the section numbers of the standard that
  18. describe this programs combination of prototype and non-prototype
  19. usage.
  20.  
  21. Thanks for any help.
  22.  
  23. Lines 1-6 show the system/compiler information
  24. Lines 8-20 show the program example
  25. Lines 21-25 show the compile, warnings and output
  26.  
  27.      1    Script started on Thu Dec 24 18:34:23 1992
  28.      2    dspsim1% uname -a
  29.      3    SunOS dspsim1 4.1.2 1 sun4m
  30.      4    dspsim1% gcc -v
  31.      5    Reading specs from /usr/local/lib/gcc-lib/sparc-sun-sunos4.1/2.3.1/specs
  32.      6    gcc version 2.3.1
  33.      7    dspsim1% cat c.c
  34.      8    #include <stdio.h>
  35.      9    main(int argc,char **argv)
  36.     10    {
  37.     11            float   f=1.0;
  38.     12    
  39.     13            func(f); /* no declaration in prototype form is visible */
  40.     14    }
  41.     15    
  42.     16    /* definition of func() is not visible  from main() */
  43.     17    func(float f)
  44.     18    {
  45.     19            printf("%f\n",f);
  46.     20    }
  47.     21    dspsim1% gcc -ansi c.c
  48.     22    c.c:11: warning: type mismatch with previous implicit declaration
  49.     23    c.c:6: warning: previous implicit declaration of `func'
  50.     24    dspsim1% a.out
  51.     25    1.875000
  52.     26    dspsim1% ^D
  53.     27    script done on Thu Dec 24 18:35:32 1992
  54.