Skip to main content
GameDev.net gamedev.net
🔒 Locked

Dev c++ compiling problem. (#include stddef.h)

Started by Orava Feb 12, 2008 at 11:40 AM 5 replies 1.3k views
Original Post
Orava
Orava
Hello, i have just started this, and i have a huge problem. Everything should be allright, but Dev c++ just seems not compile my first "Hello World" - program. What is the problem? Its the #include line that seems to have the problem when i compile and run, and i cannot understand this! Here is a picture; http://www.geocities.com/torturecod/jees.jpg Help! Im running on Windows Vista. Thanks.
SirSmokey
SirSmokey
cout is in the std namespace. you need to resolve which namespace cout is in.
There are 2 ways to do this
1. after your include statements you can use:

using namespace std;

this will allow you to use anything in the std namespace.

or
2. prefix cout with std like:
std::cout

this is the preferred method.

Edit: By the way i should let you know that Dev C++ is not supported anymore and, in my opinion, it's terrible. You should get yourself a copy of Visual Studio Express 2008 (it's free)
jouley
jouley
Quote:
Original post by SirSmokey
cout is in the std namespace. you need to resolve which namespace cout is in.
There are 2 ways to do this
1. after your include statements you can use:

using namespace std;

this will allow you to use anything in the std namespace.

or
2. prefix cout with std like:
std::cout

this is the preferred method.

There's a third method that reaches a middle ground between the two - you won't need to prefix every cout with std::, and you don't drag the entire std:: namespace where it doesn't belong. At the tightest scope that makes since:
using std::cout;
Never use using in a header file, though, as others may become angry when they use a library you've created and are forced to use the same namespaces you are. More information can be found here, on this and many other relevant topics.
Quote:
You should get yourself a copy of Visual Studio Express 2008 (it's free)

That's all sorts of good advice -- follow it!

Orava
Orava
Jeah, i added the
std:: cout<<
but it still does the same thing.

Next im gonna try to download that Visual Studio Express 2008.
SirSmokey
SirSmokey
no spaces in there
"std::cout"
Zakwayda
Zakwayda
Quote:
Original post by SirSmokey
no spaces in there
"std::cout"
Actually, it should parse correctly either way.
jonahrowley
jonahrowley
The stddef.h problem has nothing to do with the namespace problem. Or at least I really doubt it does.

I highly recommend getting VC++ 2008 though, it's a lot better. Dev-C++ never was that great and now that it's abandoned, all the more reason to seek alternatives.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.