LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-30-2005, 12:46 AM   #1
Hady
Member
 
Registered: Nov 2003
Posts: 55

Rep: Reputation: 15
.h File Inclusion in C++


Hi!

I am working in C++, I have many .cpp and .h files, and things have started to mix up with the #include "file.h" stuff...

is there any good/simple/complete tutorial that guides me what to do and how to include files when there are many interrelated files in C++ ?

or could anyone tell me about a general rule that would make my C++ experience easier?!

Thank you for your time.

Hady
 
Old 05-30-2005, 01:55 AM   #2
jonaskoelker
Senior Member
 
Registered: Jul 2004
Location: Denmark
Distribution: Ubuntu, Debian
Posts: 1,524

Rep: Reputation: 47
Quote:
is there any good/simple/complete tutorial that guides me what to do and how to include files when there are many interrelated files in C++ ?
$ touch all.h
$ for i in *.h; do echo "#include \"$i\"" >> all.h; done
(remove #include <all.h> and #ifdef-guard it)
include all.h in your .cpp files

Quote:
or could anyone tell me about a general rule that would make my C++ experience easier?!
yeah, don't use it. (ha-ha-only-serious)

hth --Jonas
 
Old 05-30-2005, 07:27 AM   #3
Chris Weimer
Member
 
Registered: Jan 2004
Location: NYC
Distribution: Fedora XFCE
Posts: 91

Rep: Reputation: Disabled
Hady - what's your problem exactly? Are you on linux? Are you using then g++? Be a little more specific and we can answer your questions.

From it sounds like, use <> for standard C++ headers and "" for headers you make.
 
Old 05-31-2005, 01:58 AM   #4
Hady
Member
 
Registered: Nov 2003
Posts: 55

Original Poster
Rep: Reputation: 15
Hi Chris!

THANKS for replying!!

Well... no, i'm not on linux (can this still be posted here!?)
I have a C++ program (No MFC, No Win Libraries), it compiles well on Visual Studio 6.0,
when I try to compile it on Dev-C++ it gives me inclusion errors?

I am using use <> for standard C++ headers and "" for my headers.

I want to know if there is any tutorial on this manner? any conventional way?

Thanks again Chris.

Hady
 
Old 05-31-2005, 07:10 AM   #5
enemorales
Member
 
Registered: Jul 2004
Location: Santiago, Chile
Distribution: Ubuntu
Posts: 410

Rep: Reputation: 31
Are you writing "#include <iostream>" or "#include <iostream.h>"? (same applies to other .h files). Maybe you also need to define some environment variables...
 
Old 05-31-2005, 08:22 PM   #6
Chris Weimer
Member
 
Registered: Jan 2004
Location: NYC
Distribution: Fedora XFCE
Posts: 91

Rep: Reputation: Disabled
I don't really know of a tutorial. But you're right do #include <iostream> for standard headers and if you got your own do #include "myown.h" - make sense?
 
Old 05-31-2005, 08:24 PM   #7
kryptonite0110
Member
 
Registered: Mar 2005
Posts: 59

Rep: Reputation: 15
are you sure your compiling it as a 16 bit program? dev-c++ i believe compiles all it's programs by default to 32 bit. also, the way i regulate all my inclusions is to put this in each file:
Code:
#ifndef __(filename)__
//code 
...
//#define __(filename)__
#endif
that way, if a file is included twice, it doesn't redefine anything in the file. what are the actual error messages it gives you?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
New ATI driver inclusion ryox03 Linux - Distributions 1 01-29-2005 07:09 PM
Failed opening '../main/mainconfig.php' for inclusion (include_path='.:/usr/local/lib ryancoolest Linux - Newbie 3 09-29-2004 09:10 PM
Odd kernel 2.6.6 inclusion vs. module support in Debian TemplaraPheonix Linux - Software 0 06-03-2004 08:25 PM
automatic header inclusion rajorshi Programming 2 11-02-2003 02:29 PM
How to play a media file/ video file/mp3 file recorded in harddisk/cd-rom arindam Linux - Newbie 2 09-05-2003 10:31 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:45 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration