Archived

This topic is now archived and is closed to further replies.

Is my compiler messed up or do I have to configure something??

This topic is 5115 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

Hi, I have VS .net 2002 (the year, I''m not so sure of).. And, I took this example from the help, and it can''t compile this: // iostream_cerr.cpp // compile with: /EHsc // By default, cerr and clog are the same as cout #include <iostream> #include <fstream> using namespace std; void TestWide( ) { int i = 0; wcout << L"Enter a number: "; wcin >> i; wcerr << L"test for wcerr" << endl; wclog << L"test for wclog" << endl; } int main( ) { int i = 0; cout << "Enter a number: "; cin >> i; cerr << "test for cerr" << endl; clog << "test for clog" << endl; TestWide( ); } Took is right out from the help!!! This is the error: fatal error C1010: unexpected end of file while looking for precompiled header directive What''s with this?? I know I copied the whole example EXACTLY! Oh, and sometimes when I put a "using namespace std;" with the headers, I get -- "std is not a namespace" thing.. What''s with this?? Is there something I have to configure.. PS: Just to remind you, I have Visual C++ .net... Battleguard
Only questions raise questions. Questions are raised by people, by curiousity, the gift of nature to all human beings. And curiosity is satisfied by answers, which in turn raise questions, which lead to answers. And this curiosity is what keeps SCIENCE alive...

Share this post


Link to post
Share on other sites
Somewhere in the project settings is an option to use pre-compiled headers. Turn that option off.

If you put "using namespace std" in a header and included that header before (or without) including one of the STL headers (iostream, vector, etc), then you will get that "not a namespace" error. The namespace has to be defined before it can be used.

Share this post


Link to post
Share on other sites
I''m looking, can''t find it, I''ll keep looking... BUT I found that if I add this:

#include <stdafx.h>

before the iostream inclusion everything works out...

Battleguard



Only questions raise questions. Questions are raised by people, by curiousity, the gift of nature to all human beings. And curiosity is satisfied by answers, which in turn raise questions, which lead to answers. And this curiosity is what keeps SCIENCE alive...

Share this post


Link to post
Share on other sites
Nope, I can''t find an option to turn off the precompiled headers...

Battleguard



Only questions raise questions. Questions are raised by people, by curiousity, the gift of nature to all human beings. And curiosity is satisfied by answers, which in turn raise questions, which lead to answers. And this curiosity is what keeps SCIENCE alive...

Share this post


Link to post
Share on other sites
Right. That file (and stdafx.cpp) were generated by VS when your project was created. They contain the stuff used by VS to create the precompiled headers. If you can find the option and turn it off, you won''t need them. I don''t have access to VS .NET, so I can''t tell you where in the project settings the option is.

In VC++ 6.0, it''s under Project/Settings... on the C/C++ tab. There''s a drop-down list that has "Precompiled Headers" in it. Maybe VS .NET is similar.

Share this post


Link to post
Share on other sites
Nope, there isn't a settings under the project menu lol..

For now, I'm just goin with adding the stdafx.h... Can someone tell me what is the use of precompiled headers?? Do I need them when making programs that context re-learning the stuff from like the types of variables.. (ya, I'm doin dat HEHE)??

BattleGuard



Only questions raise questions. Questions are raised by people, by curiousity, the gift of nature to all human beings. And curiosity is satisfied by answers, which in turn raise questions, which lead to answers. And this curiosity is what keeps SCIENCE alive...

[edited by - battleguard on December 13, 2003 1:22:23 AM]

Share this post


Link to post
Share on other sites
Found it!!!! In the class tab in the Solution Explorer, go to properties... There in C/C++ the precompiled headers suboutlining, then just choose no.. for those who don''t know, I thought I might show off... LOL

Thanx guys..

Battleguard



Only questions raise questions. Questions are raised by people, by curiousity, the gift of nature to all human beings. And curiosity is satisfied by answers, which in turn raise questions, which lead to answers. And this curiosity is what keeps SCIENCE alive...

Share this post


Link to post
Share on other sites
Precompiled headers are a technique to speed up compiles. You don''t have to use them and they can actually cause problems. Sometimes, the compiler gets confused and doesn''t pick up changes in headers. This may have been fixed in the .NET versions, but I''ve had it happen in 6.0.

At any rate, you don''t need them.

Share this post


Link to post
Share on other sites