home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / alt / msdos / programm / 3214 < prev    next >
Encoding:
Internet Message Format  |  1993-01-23  |  2.2 KB

  1. Path: sparky!uunet!cs.utexas.edu!natinst.com!natinst.com!not-for-mail
  2. From: banshee@natinst.com (Jeff Kellam)
  3. Newsgroups: alt.msdos.programmer
  4. Subject: Re: Problem with TurboC++ ???
  5. Date: 22 Jan 1993 17:12:14 -0600
  6. Organization: National Instruments, Austin, TX
  7. Lines: 43
  8. Message-ID: <1jpv0eINNf3i@eagle.natinst.com>
  9. References: <1j80c6INN456@festus.ksu.ksu.edu> <C1A0IC.I0G@icon.rose.hp.com>
  10. NNTP-Posting-Host: eagle.natinst.com
  11.  
  12. In article <C1A0IC.I0G@icon.rose.hp.com> wes@hpsmo100.rose.hp.com (Westley) writes:
  13.  
  14. [problems with declaring variables in header files omitted]
  15.  
  16. >I have seen a similar behaviour ONLY when both files (foo.c and bar.c) are
  17. > included in the same 'project'.  Turbo C will completely compile all files
  18. > related by the project list and then try to link them.  If you have an
  19. > #include that declares a variable, it will be declared in ALL files that
  20. > refer to that #include.  Then the link process will find multiply declared
  21. > variables.  
  22. >One way to avoid this is to NOT have any variable declarations in generic
  23. > #include files.  In other words, declare any variable IN each file, not in
  24. > an #include.  ONLY one of the files will need to do the actual declaration,
  25. > the others will refer to that declaration with 'extern' put in front of
  26. > their declarations.
  27. >The 'project' option in Turbo C is pretty neat, but can be dangerous if you
  28. > don't understand it completely (as I did the first few times I tried to use
  29. > it).  Good luck with your project.
  30. >
  31. >    Westley
  32. >    wes@hpsmo100.rose.hp.com
  33.  
  34. Another way to avoid this, in C, not C++, is to set the "generate COMDEFs"
  35. option to on.  When a non-initialized variable is in a header file, every
  36. module which includes that header is going to try to allocate space for it
  37. in its OBJ which generates a PUBDEF.  The COMDEF allows the linker to decide
  38. what to do about the variable and thus can help.  Note though, that
  39. the Borland will not genrerate COMDEFs when it is compiling a C++ module.
  40.  
  41. This really isn't the fault of the Project concept, since any program
  42. that does this is going to fail in the linking, whether via a project make
  43. or via the command line linker.
  44.  
  45.  
  46. Regards,
  47.  
  48.  
  49.  
  50.  
  51. Jeff K
  52.  
  53. -- 
  54. National Instruments - I work for them, not speak for them.
  55.