Broken library?

May 9, 2014 at 9:24am
I'm pretty darn sure I've done something to mess up my <cstdio>.

Whenever i'm including that lib it makes this insane error that it nested to deep while it opens the cstdio.

I'm using Codeblocks and i've tried reinstalling severel times with no luck.

Any pointers as what to do?
May 9, 2014 at 9:38am

Without seeing your code its guess work - This error occurs if the preprocessor encounters too many nested #include directives . It is usually caused by two or more files trying to include each other, leading to an infinite recursion.

Also, have you got multiple headers in your project, and in those headers do you have header guards such as

1
2
3
4
5
6
7
8
#ifndef _H_MYHEADER_
#define _H_MYHEADER_

// do your stuff



#endif 
Last edited on May 9, 2014 at 9:39am
May 9, 2014 at 9:53am
This may also occur if you have an invalid or incomplete statement somewhere in your own header. like
1
2
3
4
5
6
7
8
9
10
11
12
struct a
{
};

struct b
{

// Note: missing };

struct c
{
};
May 9, 2014 at 10:18am
That's just the problem. It occurs in every projekt, regardless what's in it.


1
2
3
4
5
6
7
8
#include <cstdio>

using namespace std;
int main()
{
    cout << "Hello, World";
    return 0;
}
May 9, 2014 at 10:51am
You don't use anything from <cstdio> in your example. (std::cout is in <iostream>)

PS. Avoid using namespace std;
http://www.gotw.ca/gotw/053.htm
May 9, 2014 at 11:04am
Thx for the link, I'll look into that later today=)

I know, but even if I use something from the link, in example getchar(), it does'nt change anything. It simply won't compile.
I'm not quite sure how to explain the problem, since the errors it makes en the build log is endless, it totally screws up:(


May 9, 2014 at 11:13am
Endless is unlikely, but very long can it be. What is the first error?
May 9, 2014 at 11:18am
It has 3 lines of "#Include nested to deeply"

Then it starts with
::fpos_t has not been declared
::clearerr has not been declared

and it goes on
May 9, 2014 at 3:11pm
Can I reinstall only the library?
May 9, 2014 at 3:36pm
could you post your code?
May 9, 2014 at 3:43pm

The best thing here as Little Bobby Tables wrote is to post the whole of your code since its pretty much guess work to everyone involved.

May 9, 2014 at 4:17pm
The thing is, there is no code. It's no matter what, as long as i include <cstdio>, then it won't compile. It stops when it meets cstdio

1
2
3
4
5
6
7
8
9
10
11
#include <iostream>
#include <cstdio>

using namespace std;

int main()
{
    printf("Hello world!") << endl;
    return 0;
}
Last edited on May 9, 2014 at 4:18pm
May 9, 2014 at 4:20pm
well see thats because printf("Hello, world!") << endl doesnt work. that has nothing to do with the stl
May 9, 2014 at 4:26pm
That's because i'm such a newb i don't even know how to code it right.

Nevertheless, the compiler never gets to the error, it stops when it gets to the #include cstdio, so it won't even tell me about my mistake =)

I'm pretty sure it's not about the code, because the compiler never get to the code, it only get to the include cstdio?
May 9, 2014 at 5:12pm
C++ compiler writers have to juggle an insane lanugage syntax with multple file inclusions and object prototypes, etc... It doesn't always catch errors where you think it ought.

Try to compile a correct program and see if the error doesn't go away.
Topic archived. No new replies allowed.