-
errors with bitset
I'm stumped as to why this code won't compile:
Code:
#include <bitset>
int main () {
std::bitset<8> b;
return 0;
}
I get a whole slew of errors from gcc (2.95.2)
Code:
\JFEAND~1\PROGS\bitset.cpp: In instantiation of `bitset<8,long unsigned int>':
\JFEAND~1\PROGS\bitset.cpp:3: instantiated from here
\JFEAND~1\PROGS\bitset.cpp:3: `CHAR_BIT' was not declared in this scope
\JFEAND~1\PROGS\bitset.cpp:3: `CHAR_BIT' was not declared in this scope
\JFEAND~1\PROGS\bitset.cpp:3: template argument 1 is invalid
..\lib\gcc-lib\i386-mingw32\2.95.2\..\..\..\..\include\bitset:541: `CHAR_BIT' was not declared in this scope
..\lib\gcc-lib\i386-mingw32\2.95.2\..\..\..\..\include\bitset:541: `CHAR_BIT' was not declared in this scope
..\lib\gcc-lib\i386-mingw32\2.95.2\..\..\..\..\include\bitset:541: template argument 1 is invalid
and so on...
any ideas?
-
Is it std:: for bitset? I don't think it is. Take out the std:: and it should work.
EDIT: I was wrong. It works fine for me though. The above code.
-
I threw it into Dev C++ 4.9.9.2 on Windows XP SP2 and it compiled fine.
-
also compiled fine with gcc 4.1.0
-
hmm... perhaps my older version of gcc has some strange implementation of bitset
-
Try this, it prob won't make any difference, but throw in a 'using namespace std;', and take away the 'std::', and see if that works.
-
Nope, same errors.
Also tried adding using std::bitset.
I think it's just a problem with my version of gcc.
I get a ton of errors about "template argument 1 is invalid" and "CHAR_BIT' was not declared in this scope"
-
I'd say if you need to do this program to get dev of something which will allow the use of <bitset>.
-
well gcc 2.95 isn't really up2date, so the implementation of the stl probably uses some constructs that were not supported back then.
-
Hmm I suppose October 27, 1999 (release date) was quite a while ago. It's probably time to upgrade.
The thing is that the build is integrated into a text editor called Jen's File Editor, and I don't know how to integrate the new compiler build.
-
> \JFEAND~1\PROGS\bitset.cpp:3: `CHAR_BIT' was not declared in this scope
You could try
#include <limits.h>
before including bitset
But your compiler sounds pretty old to me.
-
The limits.h didn't work either.
It's ok, I switched over to Dev C++ with a newer version of gcc, and it works now.
It's a better IDE anyways.
Thanks for the help.