Newsgroup: it.comp.lang.c++
Titolo: Bitset

Qualcuno sa spiegarmi per quale razza di motivo, quando vado a compilare
queste due righe di codice con il dev c++ 4...
#include <iostream.h>
#include <bitset>
int main()
{
      bitset<32> bitvec;
}
...ricevo questa valanga di errori?
c:\docume~1\untitl~2.cpp: In instantiation of `bitset<32,long unsigned
int>':
c:\docume~1\untitl~2.cpp:9:   instantiated from here
c:\docume~1\untitl~2.cpp:9: `CHAR_BIT' was not declared in this scope
c:\docume~1\untitl~2.cpp:9: `CHAR_BIT' was not declared in this scope
c:\docume~1\untitl~2.cpp:9: template argument 1 is invalid
C:\PROGRA~1\C__~1\INCLUDE\G__~1\bitset:541: `CHAR_BIT' was not declared in
this scope
C:\PROGRA~1\C__~1\INCLUDE\G__~1\bitset:541: `CHAR_BIT' was not declared in
this scope
C:\PROGRA~1\C__~1\INCLUDE\G__~1\bitset:541: template argument 1 is invalid
C:\PROGRA~1\C__~1\INCLUDE\G__~1\bitset:542: `CHAR_BIT' was not declared in
this scope
C:\PROGRA~1\C__~1\INCLUDE\G__~1\bitset:542: `CHAR_BIT' was not declared in
this scope
C:\PROGRA~1\C__~1\INCLUDE\G__~1\bitset:542: template argument 1 is invalid
C:\PROGRA~1\C__~1\INCLUDE\G__~1\bitset:543: `CHAR_BIT' was not declared in
this scope
C:\PROGRA~1\C__~1\INCLUDE\G__~1\bitset:543: `CHAR_BIT' was not declared in
this scope
C:\PROGRA~1\C__~1\INCLUDE\G__~1\bitset:543: template argument 1 is invalid
C:\PROGRA~1\C__~1\INCLUDE\G__~1\bitset:544: `CHAR_BIT' was not declared in
this scope
C:\PROGRA~1\C__~1\INCLUDE\G__~1\bitset:544: `CHAR_BIT' was not declared in
this scope
C:\PROGRA~1\C__~1\INCLUDE\G__~1\bitset:544: template argument 1 is invalid
C:\PROGRA~1\C__~1\INCLUDE\G__~1\bitset:545: `CHAR_BIT' was not declared in
this scope
C:\PROGRA~1\C__~1\INCLUDE\G__~1\bitset:545: `CHAR_BIT' was not declared in
this scope
C:\PROGRA~1\C__~1\INCLUDE\G__~1\bitset:545: template argument 1 is invalid
C:\PROGRA~1\C__~1\INCLUDE\G__~1\bitset:546: `CHAR_BIT' was not declared in
this scope
C:\PROGRA~1\C__~1\INCLUDE\G__~1\bitset:546: `CHAR_BIT' was not declared in
this scope
C:\PROGRA~1\C__~1\INCLUDE\G__~1\bitset:546: template argument 1 is invalid
C:\PROGRA~1\C__~1\INCLUDE\G__~1\bitset:547: `CHAR_BIT' was not declared in
this scope
C:\PROGRA~1\C__~1\INCLUDE\G__~1\bitset:547: `CHAR_BIT' was not declared in
this scope
C:\PROGRA~1\C__~1\INCLUDE\G__~1\bitset:547: template argument 1 is invalid
C:\PROGRA~1\C__~1\INCLUDE\G__~1\bitset:548: `CHAR_BIT' was not declared in
this scope
C:\PROGRA~1\C__~1\INCLUDE\G__~1\bitset:548: `CHAR_BIT' was not declared in
this scope
C:\PROGRA~1\C__~1\INCLUDE\G__~1\bitset:548: template argument 1 is invalid
C:\PROGRA~1\C__~1\INCLUDE\G__~1\bitset:549: `CHAR_BIT' was not declared in
this scope
C:\PROGRA~1\C__~1\INCLUDE\G__~1\bitset:549: `CHAR_BIT' was not declared in
this scope
C:\PROGRA~1\C__~1\INCLUDE\G__~1\bitset:549: template argument 1 is invalid
C:\PROGRA~1\C__~1\INCLUDE\G__~1\bitset:550: `CHAR_BIT' was not declared in
this scope
C:\PROGRA~1\C__~1\INCLUDE\G__~1\bitset:550: `CHAR_BIT' was not declared in
this scope
C:\PROGRA~1\C__~1\INCLUDE\G__~1\bitset:550: template argument 1 is invalid
C:\PROGRA~1\C__~1\INCLUDE\G__~1\bitset:551: `CHAR_BIT' was not declared in
this scope
C:\PROGRA~1\C__~1\INCLUDE\G__~1\bitset:551: `CHAR_BIT' was not declared in
this scope
C:\PROGRA~1\C__~1\INCLUDE\G__~1\bitset:551: template argument 1 is invalid
C:\PROGRA~1\C__~1\INCLUDE\G__~1\bitset:552: `CHAR_BIT' was not declared in
this scope
C:\PROGRA~1\C__~1\INCLUDE\G__~1\bitset:552: `CHAR_BIT' was not declared in
this scope
C:\PROGRA~1\C__~1\INCLUDE\G__~1\bitset:552: template argument 1 is invalid
C:\PROGRA~1\C__~1\INCLUDE\G__~1\bitset:553: `CHAR_BIT' was not declared in
this scope
C:\PROGRA~1\C__~1\INCLUDE\G__~1\bitset:553: `CHAR_BIT' was not declared in
this scope
C:\PROGRA~1\C__~1\INCLUDE\G__~1\bitset:553: template argument 1 is invalid
C:\PROGRA~1\C__~1\INCLUDE\G__~1\bitset:554: `CHAR_BIT' was not declared in
this scope
C:\PROGRA~1\C__~1\INCLUDE\G__~1\bitset:554: `CHAR_BIT' was not declared in
this scope
C:\PROGRA~1\C__~1\INCLUDE\G__~1\bitset:554: template argument 1 is invalid
C:\PROGRA~1\C__~1\INCLUDE\G__~1\bitset:555: `CHAR_BIT' was not declared in
this scope
C:\PROGRA~1\C__~1\INCLUDE\G__~1\bitset:555: `CHAR_BIT' was not declared in
this scope
C:\PROGRA~1\C__~1\INCLUDE\G__~1\bitset:555: template argument 1 is invalid
C:\PROGRA~1\C__~1\INCLUDE\G__~1\bitset:556: `CHAR_BIT' was not declared in
this scope
C:\PROGRA~1\C__~1\INCLUDE\G__~1\bitset:556: `CHAR_BIT' was not declared in
this scope
C:\PROGRA~1\C__~1\INCLUDE\G__~1\bitset:556: template argument 1 is invalid
C:\PROGRA~1\C__~1\INCLUDE\G__~1\bitset:557: `CHAR_BIT' was not declared in
this scope
C:\PROGRA~1\C__~1\INCLUDE\G__~1\bitset:557: `CHAR_BIT' was not declared in
this scope
C:\PROGRA~1\C__~1\INCLUDE\G__~1\bitset:557: template argument 1 is invalid
C:\PROGRA~1\C__~1\INCLUDE\G__~1\bitset:558: `CHAR_BIT' was not declared in
this scope
C:\PROGRA~1\C__~1\INCLUDE\G__~1\bitset:558: `CHAR_BIT' was not declared in
this scope
C:\PROGRA~1\C__~1\INCLUDE\G__~1\bitset:558: template argument 1 is invalid
C:\PROGRA~1\C__~1\INCLUDE\G__~1\bitset:559: `CHAR_BIT' was not declared in
this scope
C:\PROGRA~1\C__~1\INCLUDE\G__~1\bitset:559: `CHAR_BIT' was not declared in
this scope
C:\PROGRA~1\C__~1\INCLUDE\G__~1\bitset:559: template argument 1 is invalid
C:\PROGRA~1\C__~1\INCLUDE\G__~1\bitset:560: `CHAR_BIT' was not declared in
this scope
C:\PROGRA~1\C__~1\INCLUDE\G__~1\bitset:560: `CHAR_BIT' was not declared in
this scope
C:\PROGRA~1\C__~1\INCLUDE\G__~1\bitset:560: template argument 1 is invalid
C:\PROGRA~1\C__~1\INCLUDE\G__~1\bitset:537: `CHAR_BIT' was not declared in
this scope
C:\PROGRA~1\C__~1\INCLUDE\G__~1\bitset:537: `CHAR_BIT' was not declared in
this scope
C:\PROGRA~1\C__~1\INCLUDE\G__~1\bitset:537: template argument 1 is invalid
C:\PROGRA~1\C__~1\INCLUDE\G__~1\bitset:815: confused by earlier errors,
bailing out
Grazie
Stefano

 ...ricevo questa valanga di errori?
...hai provato con un "using namespace std" ?
Massimo


Si ma non cambia di una virgola.
Stefano

 ...ricevo questa valanga di errori?
L'unico errore del programma e' che manca std::, ma il compilatore
non sembra lamentarsi di questo.  Se anche con std:: o using 
continua a dare errori si tratta di un bug del compilatore, o
piu' probabilemnte della libreria standard.
Dai messaggi sembra che il compialtore si lamenti della mancanza
di CHAR_BIT, quindi puoi provare a includere <climits> prima di
<bitset>, anche se in teoria non dovrebbe essere necessario.
	Mauro

 ...ricevo questa valanga di errori?
Prova a togliere il .h a iostream e se ancora non funziona prova con un
altro compilatore.
EMG

#include <iostream>
#include <bitset>
int main()
{
 std::bitset<32> bitvec;
 return 0;
}
compilato con il Borland C++ 5.5 non restituisce nessun errore. Magari
cambia compilatore ;)


Niente. Manco cosi' funziona. La cosa veramente fastidiosa e' che compilando
il codice che ho inserito come esempio in precedenza con il visual C++ 6.0
(aggiungendo using namespace std), tutto va bene e non mi da errori,
compilandolo con il dev mi tira fuori quella sfilza di errori!

 writes:

Cambia compilatore:
MLO@pcdf0 9 $ cat foo.cxx
#include <iostream>
#include <bitset>
#include <limits>
int main() {
  std::cout << "42 come unsigned short e' "
            << std::bitset<std::numeric_limits<unsigned short>::digits>(42)
            << std::endl;
  std::cout << "e come unsigned di 11 bits e' "
            << std::bitset<11>(42)
            << std::endl;
}
MLO@pcdf0 10 $ KCC -o foo foo.cxx && ./foo
42 come unsigned short e' 0000000000101010
e come unsigned di 11 bits e' 00000101010
MLO@pcdf0 11 $
-- 
Maurizio Loreti                         
http://www.pd.infn.it/~loreti/mlo.html
Univ. of Padova, Dept. of Physics - Padova, Italy            
lor...@pd.infn.it

 compilandolo con il dev mi tira fuori quella sfilza di errori!
non c'č niente di strano... quel pezzo di codice č giusto, e se il
compilatore ha un minimo di serietą, te lo compila! forse il problema č
nella libreria del Dev...