[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 427
  • Last Modified:

include files in turbo c++ 3.0 (dos version)

i'm using tc++ 3.0.
as far as i know, if i place a statement:
#include "file.h"
in my source, the compiler will search the "file.h" in the directory that my source locates.
if i place:
#include <iostream.h>
the compiler will go the the "include" directory that I set in the Option->Directories.
however, now i open a source in a dir "c:\temp", this file includes the "file.h" which are in c:\temp too.
but i can run the program, the compiler said:
"unable to open the include file "file.h".

so what should i do in order to run the program successfully?
(i'm using the tc++ 3.0 under win98.)

tks!!
0
chuyan
Asked:
chuyan
  • 6
  • 3
  • 2
  • +4
1 Solution
 
arunmCommented:
Assuming you "include paths" are set correctly, which is doubtful, as you program should work. Have you tried #include "c:\temp\file.h" to see if it works?

0
 
NullTerminatorCommented:
When you say yoou open the source in c:\temp, do you mean you also included that file in your project, or is another copy of the source sitting somewhere else?
'\0'
0
 
messiahCommented:
Assuming your directories are configured correctly Options->Directories, include should be C:\TC\INCLUDE (or whatever your directory is), that shouldn't be the problem.

Take these steps:

1) Make sure C:\TC\BIN is in your path
2) Go to the directory where you want to compile
3) Make sure file.h exists
4) Run TC.EXE (this will work if it's in your path!:)
5) Open up your program
6) Make sure it says EXACTLY   #include "file.h"
7) Run it

This should work, if by some odd reason it doesn't, RECHECK the spelling of the header file you're including (file.h) vs. the actual file name. If it's all correct, try putting file.h into the c:\tc\include directory, and using #include <file.h>, that's all I can think of. If you follow those steps, you should be fine. If all else fails, just re-install Turbo C++ :)

0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
chuyanAuthor Commented:
messiah,
I have tried, but it still doesn't work.

I know copying the .h file into the include directory will work, but i just want to avoid doing that.
so........any other methods can help?
0
 
AlexVirochovskyCommented:
There 2 2 possibility make this:
1.You must write in you's c:\temp  files:
  #include "c:\maindir\file.h" (if you h file in maindir)
 With such include translator find h files in exactly place
OR
2. in you's c:\temp  files:   "c:\temp\file.h" (if you h file in temp)
Regards, Alex
0
 
chuyanAuthor Commented:
sorry alex,
your answer is more or less the same as b4.

0
 
chuyanAuthor Commented:
now, it seems that my problem is solved by entering the exact path of the header file (e..g #include "c:\temp\file.h".
i can compile <press alt-F9> the source file successfully.  However, when i run the file by pressing ctrl-F9, errors appeared.  sometimes it will say "undefined symbol xxxx::xxx() in module xxxxxxxxxxxxxxxxxxxxxxxxxx"
but i'm sure that the function is properly defined in the class defined in the header file.
so can anyone tell me what's happenning?

Tks alot!!

0
 
arunmCommented:
You still have serious problem there chuyan, You shouldnt have to use the absolute path.
Ive no idea what it is though?

0
 
NullTerminatorCommented:
The undefined symbol is indicating 1) either the cpp source is not identified as part of the project,
2) possibly the function definition is not identified as a member of the class with the scope resolution operator  MyClass::theFunction() { ... }
3) the function signature does not match,  perhaps return type is missing or differnet or an argument type is missing or different.

My suggestion,
start a new project, include all the source files into the new project as you expect them to be, turn up all the warning levels to maximum and do a rebuild all, both in debug and release..  

Post the project files somewhere.  I am curious as to why Borland is having such difficulty recognizing the basic include functionality

'\0'
0
 
chuyanAuthor Commented:
Null,

can i ask you sth first? does TC++ 3.0 support the data type "bool"?

0
 
NullTerminatorCommented:
bool wasn't defined as part of ANSI C standard.
Some standard libraries might impliment it.  It is included in proposed ANSI C++ standard.

Common practice is to typedef BOOL as a short or enum it.
enum BOOL (FALSE = 0, TRUE) is more restrictive as an enum since TRUE can only be 1, where in the more traditional sense TRUE is consider anything non zero.

More Flexible is
#define FALSE 0
#define TRUE !FALSE

depends somewhat on your style
'\0'
0
 
MatthewLCommented:
I agree with the earlier comment that you should specify the path for your header file.  However the poster forgot to do double backslashes, instead of single.

i.e.

#include "c:\\temp\\file.h"



0
 
chuyanAuthor Commented:
sorry, single back slash is ok already.
0
 
newexpertCommented:
Goto File Menu -> Change Current Path to C:\TEMP
0
 
chuyanAuthor Commented:
tks
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

  • 6
  • 3
  • 2
  • +4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now