C Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesC Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old September 12th, 2009, 08:44 AM
cyborg360 cyborg360 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2009
Posts: 34 cyborg360 Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: 8 h 28 m 10 sec
Reputation Power: 0
H and cpp files - trying to build a file

Am I missing something in the h file? How can I get this to build?

My h file
Code:
#include "test30.cpp"
#include <iostream>


My cpp file
Code:
#include <iostream>
#include "test30.h"
using namespace std;

namespace first
{
  int x = 5;
  int y = 10;
}

namespace second
{
  double x = 3.1416;
  double y = 2.7183;
}

int main () {
  using first::x;
  using second::y;
  cout << x << endl;
  cout << y << endl;
  cout << first::y << endl;
  cout << second::x << endl;
  return 0;
}


I get the error:
test30.cpp(2): fatal error C1014: too many include files : depth = 1024

I bet someone on here can answer this in less than 10 seconds.

Reply With Quote
  #2  
Old September 12th, 2009, 08:49 AM
Oler1s Oler1s is offline
Contributing User
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Jul 2006
Posts: 2,270 Oler1s User rank is General 11st Grade (Above 100000 Reputation Level)Oler1s User rank is General 11st Grade (Above 100000 Reputation Level)Oler1s User rank is General 11st Grade (Above 100000 Reputation Level)Oler1s User rank is General 11st Grade (Above 100000 Reputation Level)Oler1s User rank is General 11st Grade (Above 100000 Reputation Level)Oler1s User rank is General 11st Grade (Above 100000 Reputation Level)Oler1s User rank is General 11st Grade (Above 100000 Reputation Level)Oler1s User rank is General 11st Grade (Above 100000 Reputation Level)Oler1s User rank is General 11st Grade (Above 100000 Reputation Level)Oler1s User rank is General 11st Grade (Above 100000 Reputation Level)Oler1s User rank is General 11st Grade (Above 100000 Reputation Level)Oler1s User rank is General 11st Grade (Above 100000 Reputation Level)Oler1s User rank is General 11st Grade (Above 100000 Reputation Level)Oler1s User rank is General 11st Grade (Above 100000 Reputation Level)Oler1s User rank is General 11st Grade (Above 100000 Reputation Level)Oler1s User rank is General 11st Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 4 Days 15 h 34 m 57 sec
Reputation Power: 1735
Why is the header file including the source file?

EDIT: You wrote that line of code. I'm asking what motivated you to do so.
__________________
When you ask a question, be prepared to tell us: what have you tried? If you think you don't need to try anything, we will never be interested in helping you. If you agree with the link, and you refuse to answer that question, you are being a hypocrite.

Need help with broken code? Your question should be like a good bug report: (1) It has the smallest number of steps to reproduce the problem you see (2) It tells us precisely what you expected to see and (3) It tells us what you saw and how it differed from what you expected. We need all three to help you.
Want better answers? Tell us what you Googled for and what steps you took to answer your own question.

Reply With Quote
  #3  
Old September 12th, 2009, 08:51 AM
cyborg360 cyborg360 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2009
Posts: 34 cyborg360 Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: 8 h 28 m 10 sec
Reputation Power: 0
kinda new to this. just trying things to get this to build.

Reply With Quote
  #4  
Old September 12th, 2009, 08:56 AM
Oler1s Oler1s is offline
Contributing User
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Jul 2006
Posts: 2,270 Oler1s User rank is General 11st Grade (Above 100000 Reputation Level)Oler1s User rank is General 11st Grade (Above 100000 Reputation Level)Oler1s User rank is General 11st Grade (Above 100000 Reputation Level)Oler1s User rank is General 11st Grade (Above 100000 Reputation Level)Oler1s User rank is General 11st Grade (Above 100000 Reputation Level)Oler1s User rank is General 11st Grade (Above 100000 Reputation Level)Oler1s User rank is General 11st Grade (Above 100000 Reputation Level)Oler1s User rank is General 11st Grade (Above 100000 Reputation Level)Oler1s User rank is General 11st Grade (Above 100000 Reputation Level)Oler1s User rank is General 11st Grade (Above 100000 Reputation Level)Oler1s User rank is General 11st Grade (Above 100000 Reputation Level)Oler1s User rank is General 11st Grade (Above 100000 Reputation Level)Oler1s User rank is General 11st Grade (Above 100000 Reputation Level)Oler1s User rank is General 11st Grade (Above 100000 Reputation Level)Oler1s User rank is General 11st Grade (Above 100000 Reputation Level)Oler1s User rank is General 11st Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 4 Days 15 h 34 m 57 sec
Reputation Power: 1735
Quote:
kinda new to this. just trying things to get this to build.
Yes, we can tell you are new. And it's obvious you want to fix the problems. I'm trying to get you to learn something here.

You haven't answered my question.

Reply With Quote
  #5  
Old September 12th, 2009, 11:31 AM
clifford's Avatar
clifford clifford is offline
Contributing User
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Aug 2003
Location: UK
Posts: 4,808 clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 2 Days 17 h 43 m 11 sec
Reputation Power: 1800
File inclusion inserts the text of one source into another. What do you think happens when file A includes file B and file B includes file A? If the preprocessor or your IDE's dependency generator were not smart enough to spot it, a recursively infinitely growing file; that is what.

It does not matter how new you are to something, most newbs start by copying something that works, and you will not have seen this any where.

If that is your entire header file, it is entirely pointless, since if you remove the cpp inclusion (never include a cpp file BTW), you are left with <iostream> which your CPP file already includes. Nothing in your .cpp file needs anything that is not already in your cpp file or in iostream, so what is it for?

If when you write 'sensible' code it does not compile, post the code and the compile log and we can help.

Reply With Quote
  #6  
Old September 26th, 2009, 09:49 PM
cdh473 cdh473 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2009
Location: Georgia, USA
Posts: 13 cdh473 Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: 7 h 40 m 16 sec
Reputation Power: 0
Send a message via Yahoo to cdh473 Send a message via Skype to cdh473 Send a message via XFire to cdh473
MySpace
Code:
#include <iostream>
using namespace std;

int firstX() {
  return 5;
};

int firstY() {
  return 10;
};

double secondX() {
  return 3.1416;
};

double secondY() {
  return 2.7183;
};



int main () {
  cout << firstX() << endl;
  cout << firstY() << endl;
  cout << firstY() << endl;
  cout << secondX() << endl;
  cin.get();
  return 0;
}

I believe this is what you're trying to do?
It should be just 1 file, if you're trying to do this ^.
The only thing you need to include is iostream

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesC Programming > H and cpp files - trying to build a file

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap