home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / lang / c / 19593 < prev    next >
Encoding:
Text File  |  1993-01-12  |  1.4 KB  |  48 lines

  1. Newsgroups: comp.lang.c
  2. Path: sparky!uunet!cs.utexas.edu!csc.ti.com!tilde.csc.ti.com!mksol!mccall
  3. From: mccall@mksol.dseg.ti.com (fred j mccall 575-3539)
  4. Subject: Re: Where to include
  5. Message-ID: <1993Jan12.185243.20147@mksol.dseg.ti.com>
  6. Organization: Texas Instruments Inc
  7. References: <C0ID0z.504@ulowell.ulowell.edu>
  8. Date: Tue, 12 Jan 1993 18:52:43 GMT
  9. Lines: 37
  10.  
  11. In <C0ID0z.504@ulowell.ulowell.edu> vpham@cs.ulowell.edu (vinh) writes:
  12.  
  13.  
  14.  
  15. >fun()
  16. >{
  17. >}
  18.  
  19. >#include <stdio.h>
  20.  
  21.  
  22. >fun2()
  23. >{
  24. >    printf("test...");
  25. >}
  26.  
  27. >we argued at work about where to put stdio.h; obviously fun()
  28. >isn't calling anything declared in <stdio.h>, so  don't think
  29. >stdio.h should be included at the beginning of the file; my
  30. >co-fellow worker thinks it's ugly ; what do you think?
  31. >what does the standard say? what does K&R say?
  32.  
  33. This is one of those maintenance oriented stylistic issues.  Putting
  34. the '#include' statements anywhere but the top of the file is a
  35. maintenance problem waiting to happen.  The '#include' has file scope,
  36. and so should reasonably occur once at the top of the file.  Doing it
  37. the way you show above almost 'feels' like you want it to have FUNCTION
  38. scope, instead.
  39.  
  40.  
  41.  
  42.  
  43. -- 
  44. "Insisting on perfect safety is for people who don't have the balls to live
  45.  in the real world."   -- Mary Shafer, NASA Ames Dryden
  46. ------------------------------------------------------------------------------
  47. Fred.McCall@dseg.ti.com - I don't speak for others and they don't speak for me.
  48.