Jump to content
  • Advertisement
Sign in to follow this  
BringBackFuturama

I "Confused" My Compiler!?

This topic is 4576 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Wow. :| Well I'm sure this has to do with strings and pointers. I probably tried to print by address or something wrong. Anyway...get this error: "/stddef.h:153: confused by earlier errors, bailing out" My compiler bailed on me! :D Seriously though, this is strange. It told me all the errors are in stddef.h. What could I have possibly done that would've caused that?

Share this post


Link to post
Share on other sites
Advertisement
Care to list the other errors? If it tells you that there are so many errors, it can't even look for any more, maybe you should worry about those. If the error is in seperate file, there are a couple things that could have happened. Check before you include the file for any missing semicolons or other syntax errors. Also, are you sure you didn't accidentally change anything with the file?

Share this post


Link to post
Share on other sites
Quote:
Original post by Sr_Guapo
Care to list the other errors? If it tells you that there are so many errors, it can't even look for any more, maybe you should worry about those. If the error is in seperate file, there are a couple things that could have happened. Check before you include the file for any missing semicolons or other syntax errors. Also, are you sure you didn't accidentally change anything with the file?


Yeah sure...here's the complete listing:

[SOURCE]C:\Documents and Settings\(MY NAME)\My Documents\Assignment 6>g++ -c PrintData.cpp
In file included from PrintData.cpp:1:
stocks.h:47:7: warning: no newline at end of file
In file included from C:/Documents and Settings/(MY NAME)/My Documents/School/(MY SCHOOL)/11th Grade/Qua
rter 2/Intro to C/MinGW/include/c++/3.2.3/iosfwd:45,
from C:/Documents and Settings/(MY NAME)/My Documents/School/(MY SCHOOL)/11th Grade/Qua
rter 2/Intro to C/MinGW/include/c++/3.2.3/ios:44,
from C:/Documents and Settings/(MY NAME)/My Documents/School/(MY SCHOOL)/11th Grade/Qua
rter 2/Intro to C/MinGW/include/c++/3.2.3/ostream:45,
from C:/Documents and Settings/(MY NAME)/My Documents/School/(MY SCHOOL)/11th Grade/Qua
rter 2/Intro to C/MinGW/include/c++/3.2.3/iostream:45,
from PrintData.cpp:2:
C:/Documents and Settings/(MY NAME)/My Documents/School/(MY SCHOOL)/11th Grade/Quarter 2/Intro to C/MinG
W/include/c++/3.2.3/bits/stringfwd.h: In
function `char* GetMonth(int)':
C:/Documents and Settings/(MY NAME)/My Documents/School/(MY SCHOOL)/11th Grade/Quarter 2/Intro to C/MinG
W/include/c++/3.2.3/bits/stringfwd.h:46: parse
error before `namespace'
C:/Documents and Settings/(MY NAME)/My Documents/School/(MY SCHOOL)/11th Grade/Quarter 2/Intro to C/MinG
W/include/c++/3.2.3/bits/stringfwd.h:54: parse
error before `<' token
C:/Documents and Settings/(MY NAME)/My Documents/School/(MY SCHOOL)/11th Grade/Quarter 2/Intro to C/MinG
W/include/c++/3.2.3/bits/stringfwd.h:58: explicit
specialization in non-namespace scope `char* GetMonth(int)'
C:/Documents and Settings/(MY NAME)/My Documents/School/(MY SCHOOL)/11th Grade/Quarter 2/Intro to C/MinG
W/include/c++/3.2.3/bits/stringfwd.h:58: `
char_traits' is not a template
C:/Documents and Settings/(MY NAME)/My Documents/School/(MY SCHOOL)/11th Grade/Quarter 2/Intro to C/MinG
W/include/c++/3.2.3/bits/stringfwd.h:60: syntax
error before `;' token
C:/Documents and Settings/(MY NAME)/My Documents/School/(MY SCHOOL)/11th Grade/Quarter 2/Intro to C/MinG
W/lib/gcc-lib/mingw32/3.2.3/include/stddef.h:153: confused by earlier errors, bailing out[/SOURCE]

Share this post


Link to post
Share on other sites
Maybe if you could post your code, it may make a bit more sense. It looks like this is a homework assignment, so we can't really just tell you the answer, but we can definately help point you in the correct direction!

Share this post


Link to post
Share on other sites
Try posting where you include cstddef (or whatever includes it) and the code right before it.

Share this post


Link to post
Share on other sites
Quote:
Original post by Sr_Guapo
Maybe if you could post your code, it may make a bit more sense. It looks like this is a homework assignment, so we can't really just tell you the answer, but we can definately help point you in the correct direction!


Ah don't worry. It was a homework assignment, but I gave up on it because my approach was way off. (it's only like 1% of my grade and it's due tommorow, the last day of class, anyway)

But sure..you can look at the code. Like I said though, I'm pretty sure it's a string problem. My teacher never taught us to use C++ strings, just character arrays.

[SOURCE]#include "stocks.h"
#include <iostream>


void PrintData(struct stock &x)
{
int i = 0;
for(;;)
{
cout << " " // CENTERING
<< x.symbol << ':' << GetYear(i);

for(;;)
{
if( (i-1)%372 = 0) break;
cout << "\n" << GetMonth(i)
<< " "
<< "*-----Open----* *-----High----*"
<< "*----Low ----* *----Close----* "
<< " "
<< "Max Min Max Min"
<< " Max Min Max Min"
<< endl;

}
}
}

int GetYear(int i) { if(i < 372) return 2004; else return 2005;}

char * GetMonth(int i)
{
float j = (i-1)/31;
if(j < 1) return "Jan.";
if(j < 2) return "Feb.";
if(j < 3) return "Mar.";
if(j < 4) return "Apr.";
if(j < 5) return "May.";
if(j < 6) return "Jun.";
if(j < 7) return "Jul.";
if(j < 8) return "Aug.";
if(j < 9) return "Sep.";
if(j < 10)return "Oct.";
if(j < 11)return "Nov.";
if(j < 12)return "Dec.";
if(j < 13)return "Jan.";
if(j < 14)return "Feb.";
if(j < 15)return "Mar.";
if(j < 16)return "Apr.";
if(j < 17)return "May.";
if(j < 18)return "Jun.";
if(j < 19)return "Jul.";
if(j < 20)return "Aug.";
if(j < 21)return "Sep.";
if(j < 22)return "Oct.";
if(j < 23)return "Nov.";
else return "Dec.";
}[/SOURCE]

Share this post


Link to post
Share on other sites
EDIT: Nevermind.


That's some ugly code. The use of char* for strings in C++ is, as you mentioned, particularly nasty. The most obvious think I see is that you need to qualify objects in the std namespace (std::cout) or insert a "using std::cout" or "using namespace std" near the top someplace. Unless stocks.h has it... but that would be evil as well.

Use std::string unless your teacher/professor has explicitly forbid it (or explicitly required char*... in which case change the return type of GetMonth() to const char* at least).

Share this post


Link to post
Share on other sites
Quote:
Original post by CTar
Try posting where you include cstddef (or whatever includes it) and the code right before it.


But i don't. :| I just included iostream and my own header file.

Share this post


Link to post
Share on other sites
For a start - put some newlines at the end of your "stocks.h" file.
Unlike Visual C++, gcc has some problems if there is no newline symbols at the end of included header file (had some problems with this issue myself).

EDIT: you don't have any 'using' statements, but you use cout and endl as if they are not in std namespace - either you didn't post all code, or you missed it.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!