Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

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

Posted on 1998-10-16
15
407 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
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 

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
 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are two main kinds of selectors in CSS: One is base selector like h1, h2, body, table or any existing HTML tags.  For instance, the following rule sets all paragraphs (<p> elements) to red: (CODE) CSS also allows us to define our own custom …
JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

839 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