Cant use std lib.

  • Thread starter Thread starter G123456
  • Start date Start date
G

G123456

I am using Microsoft Visual Studio 2005 Prof.
I am (only) using the C++ part of it (or i think so).

When i am compiling my code i get the error "error C2653: 'std' : is not a
class or namespace name"
If i try to use "using namespace std" i get the error "error C2871: 'std' :
a namespace with this name does not exist"

But if i write "std::" i get a list of posibilitis.

Whot am i doing wrong ?
Is there somthing missing under the installation ?

// G123456
 
G123456 said:
I am using Microsoft Visual Studio 2005 Prof.
I am (only) using the C++ part of it (or i think so).

When i am compiling my code i get the error "error C2653: 'std' : is not a
class or namespace name"
If i try to use "using namespace std" i get the error "error C2871: 'std'
: a namespace with this name does not exist"

But if i write "std::" i get a list of posibilitis.

Whot am i doing wrong ?

What header files have you included?

The standard library comes with the compiler, but it is not part of it. You
must request it using #include just like any third-party library.
 
When i am compiling my code i get the error "error C2653: 'std' : is not a
class or namespace name"
If i try to use "using namespace std" i get the error "error C2871: 'std' :
a namespace with this name does not exist"

What headers are you #include 'ing? You need to include the headers
which reference 'std::' before you can refer to it.

Nathan Mates
 
Nathan said:
What headers are you #include 'ing? You need to include the headers
which reference 'std::' before you can refer to it.

....and, annoyingly, Intellisense knows about everything in std, even if you
haven't included the necessary headers. The compiler is not so clairvoyant.

-cd
 
Ben Voigt said:
What header files have you included?
My headers look like:
#include <queue>
#include <vector>
#include <list> // bruges i funk_xyz
#include <iostream>
//#include <System>
#include "std"
#include "stdafx.h";
using namespace std;
 
Carl Daniel said:
...and, annoyingly, Intellisense knows about everything in std, even if
you haven't included the necessary headers. The compiler is not so
clairvoyant.

-cd
My problems are: I wont to make use of a queue of userdefind types

I think this will do it :
std::queue <char> q1;
queue<int> Koe; // shoot have been: queue<koeType> Koe;

But booth lines generate the errors:
error C2143: syntax error : missing ';' before '<'
error C4430: missing type specifier - int assumed. Note: C++ does not
support default-int
 
G123456 said:
My headers look like:
#include <queue>
#include <vector>
#include <list> // bruges i funk_xyz
#include <iostream>
//#include <System>
#include "std"
#include "stdafx.h";
using namespace std;
It dosen�t matter of i use <std> or "std".

G123456:

What is the file "std"?

If this is a "normal" project then #include "stdafx.h" should be the
first non-commented line in the file.

Can you demonstrate this problem in a simple single-file console
application? Try to reduce the problem to the most minimal content that
you can, and then post the whole code.
 
G123456 said:
My headers look like:
#include <queue>
#include <vector>
#include <list> // bruges i funk_xyz
#include <iostream>
//#include <System>
#include "std"
#include "stdafx.h";

If you have precompiled headers, then everything up to "stdafx.h" is
ignored. The compiler, instead of processing all the headers, uses the
precompiled data frozen after compiling stdafx.cpp. Add your #include
statements to stdafx.h instead of your .cpp file, then they will be included
in the precompiled data.
 
My problems are: I wont to make use of a queue of userdefind types

I think this will do it :
std::queue <char> q1;
queue<int> Koe; // shoot have been: queue<koeType> Koe;

But booth lines generate the errors:
error C2143: syntax error : missing ';' before '<'
error C4430: missing type specifier - int assumed. Note: C++ does not
support default-int

Have you #included <queue>?

Are you compiling a .cpp file? (If the file's extension is .c or .C, it
will be compiled as C, not C++).

-cd
 
Ben Voigt said:
If you have precompiled headers, then everything up to "stdafx.h" is
ignored. The compiler, instead of processing all the headers, uses the
precompiled data frozen after compiling stdafx.cpp. Add your #include
statements to stdafx.h instead of your .cpp file, then they will be
included in the precompiled data.

Hei Bent.

When i moved #include stdafh.h up in front,
lot of the errors dissapered - thanks for that idea.

//G123456
 
Back
Top