Solved

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

Posted on 1998-10-16
15
402 Views
Last Modified: 2013-11-18
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
Comment
Question by:chuyan
  • 6
  • 3
  • 2
  • +4
15 Comments
 
LVL 3

Expert Comment

by:arunm
ID: 1175309
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
 
LVL 3

Expert Comment

by:NullTerminator
ID: 1175310
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
 
LVL 1

Expert Comment

by:messiah
ID: 1175311
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
 

Author Comment

by:chuyan
ID: 1175312
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
 
LVL 14

Expert Comment

by:AlexVirochovsky
ID: 1175313
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
 

Author Comment

by:chuyan
ID: 1175314
sorry alex,
your answer is more or less the same as b4.

0
 

Author Comment

by:chuyan
ID: 1175315
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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 3

Expert Comment

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

0
 
LVL 3

Expert Comment

by:NullTerminator
ID: 1175317
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
 

Author Comment

by:chuyan
ID: 1175318
Null,

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

0
 
LVL 3

Expert Comment

by:NullTerminator
ID: 1175319
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
 
LVL 1

Expert Comment

by:MatthewL
ID: 1175320
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
 

Author Comment

by:chuyan
ID: 1175321
sorry, single back slash is ok already.
0
 
LVL 1

Accepted Solution

by:
newexpert earned 30 total points
ID: 1175322
Goto File Menu -> Change Current Path to C:\TEMP
0
 

Author Comment

by:chuyan
ID: 1175323
tks
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now