home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: alt.msdos.programmer
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!sdd.hp.com!hpscit.sc.hp.com!icon.rose.hp.com!wes
- From: wes@hpsmo100.rose.hp.com (Westley)
- Subject: Re: Problem with TurboC++ ???
- Sender: news@icon.rose.hp.com (News Administrator)
- Message-ID: <C1A0IC.I0G@icon.rose.hp.com>
- Date: Fri, 22 Jan 1993 22:15:48 GMT
- References: <1j80c6INN456@festus.ksu.ksu.edu>
- Organization: one end of the world
- X-Newsreader: TIN [version 1.1.8 PL6]
- Lines: 32
-
- Steven D. Marcotte (sdoran@festus.ksu.ksu.edu) wrote:
- >
- > I ran across a problem when trying to compile a program the
- >other day. Turbo C seems to think that when I define a varible in
- >a header file, it should associate it with all the files and the
- >compiler comes back and tells me something like:
- > for file bar.c _x already declared in foo.c
- >
- [...]
- >
- > It compiles correctly on the school's UNIX box using cc and gcc
- >I just can't get Turbo C++ to work right. Any suggestions to why it is
- >doing this? Thanks...
- >
-
- I have seen a similar behaviour ONLY when both files (foo.c and bar.c) are
- included in the same 'project'. Turbo C will completely compile all files
- related by the project list and then try to link them. If you have an
- #include that declares a variable, it will be declared in ALL files that
- refer to that #include. Then the link process will find multiply declared
- variables.
- One way to avoid this is to NOT have any variable declarations in generic
- #include files. In other words, declare any variable IN each file, not in
- an #include. ONLY one of the files will need to do the actual declaration,
- the others will refer to that declaration with 'extern' put in front of
- their declarations.
- The 'project' option in Turbo C is pretty neat, but can be dangerous if you
- don't understand it completely (as I did the first few times I tried to use
- it). Good luck with your project.
-
- Westley
- wes@hpsmo100.rose.hp.com
-