home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / std / c / 2518 < prev    next >
Encoding:
Text File  |  1992-08-26  |  1.5 KB  |  44 lines

  1. Newsgroups: comp.std.c
  2. Path: sparky!uunet!taumet!steve
  3. From: steve@taumet.com (Steve Clamage)
  4. Subject: Re: space optimization involving enum
  5. Message-ID: <1992Aug26.184220.8236@taumet.com>
  6. Organization: TauMetric Corporation
  7. References: <spuler.714711530@coral.cs.jcu.edu.au> <1992Aug25.153909.17977@email.tuwien.ac.at> <17dvn3INNglh@early-bird.think.com>
  8. Date: Wed, 26 Aug 1992 18:42:20 GMT
  9. Lines: 33
  10.  
  11. barmar@think.com (Barry Margolin) writes:
  12.  
  13. >Actually, doesn't the standard require that function
  14. >declarations/prototypes and definitions be consistent with each other?  If
  15. >the function is defined with an ANSI parameter list, the caller must have a
  16. >prototype in scope.  If the function is defined with a K&R1 parameter list,
  17. >the caller can use an old-style declaration (or no declaration at all,
  18. >letting it default, if the function returns int).
  19.  
  20. Not quite.  You are allowed to mix prototype and non-prototype
  21. declarations and definition of the same function, provided the
  22. promotions implied by the non-prototype declaration/definition
  23. do not result in any changes.  In practice, this means not using
  24. any parameters of type char, short, or float.  If enums are smaller
  25. than ints, avoid those too.
  26.  
  27. Conforming examples:
  28.  
  29. int foo(int, long, double); /* prototype */
  30.  
  31. foo(i, l, d) /* implicit int return and int type for 'i' */
  32. long l;
  33. double d;
  34. { ... }
  35.  
  36. int bar();    /* declaration */
  37.  
  38. int bar(int i, long l, double d) /* prototyped header */
  39. { ... }
  40. -- 
  41.  
  42. Steve Clamage, TauMetric Corp, steve@taumet.com
  43. Vice Chair, ANSI C++ Committee, X3J16
  44.