Ĺadny brzuch
Czy moglibyście mi wskazać gdzie(i jaki) jest tu błąd?
Sory za takie pytanie, ale sam probowalem i nie moglem sobie poradzic z problemem. To jest kod przepisany z "Perełek Programowania Gier Tom 1." z rozdziału o uchwytach. Na początku sam próbowałem, ale też był ten błąd, aż w końcu przepisałem wszystko dokładnie z książki i błąd dalej istniał ten sam.
template <typename TAG> class Handle { union { enum { // rozmiary pól w bitach MAX_BITS_INDEX = 16; MAX_BITS_MAGIC = 16; // Maksymalne wartości pól. Przydadzą się w instrukcjach assert; MAX_INDEX = ( 1 << MAX_BITS_INDEX) - 1; MAX_MAGIC = ( 1 << MAX_BITS_MAGIC) - 1; }; struct { unsigned m_Index : MAX_BITS_INDEX; // index tablicy zasobów unsigned m_Magic : MAX_BITS_MAGIC; // magiczna liczba dotycząca // testowania }; unsigned int m_Handle; }; public: // Inicjalizacja Handle( void ) : m_Handle( 0 ) { } void Init( unsigned int index ); // Zapytania. unsigned int GetIndex ( void ) const { return ( m_Index ); } unsigned int GetMagic ( void ) const { return ( m_Magic ); } unsigned int GetHandle( void ) const { return ( m_Handle ); } bool IsNull ( void ) const { return ( !m_Handle ); } operator unsigned int ( void ) const { return ( m_Handle ); } };
oto co wyświetla kompilator
error C2065: 'MAX_BITS_MAGIC' : undeclared identifier see reference to class template instantiation 'Handle<TAG>' being compiled error C2149: 'm_Magic' : named bit field cannot have zero width see reference to class template instantiation 'Handle<TAG>' being compiled
Z góry dziękuje za wszystkie odpowiedzi :)
Wartości w enumie odziela się przecinkami, a nie średnikami
znowu pewnie zrobilem glupi blad(program sie kompiluje ale wyswietla sie mnustwo ostrzezen)
#include <map> #include <algorithm> typedef unsigned short u16; typedef Handle<BaseResource> hRes; typedef std::map<u16,hRes> ResMap; typedef ResMap::iterator ResMapItor;
Czy widzicie tu blad/niescislosc ?
jakby ktos potrzebowal moge podac te ostrzezenia ale jest ich troche duzo
typedef Handle<BaseResource> hRes;
co to jest Handle ?
co to jest Handle ?
Moze jednak pokaz te warningi, bo to jest teraz taki toto lotek :P
Moze jednak pokaz te warningi, bo to jest teraz taki toto lotek :P
Nieco powalone to chyba jest, bo po zmienieniu 'unsigned' na 'signed' warningow jest tylko 4
typedef signed short s16; typedef Handle<BaseResource> hRes; typedef std::map<s16,hRes> ResMap; typedef ResMap::iterator ResMapItor;
--------------------Configuration: MESH - Win32 Debug-------------------- Compiling... winmain.cpp n:\game\0,01\mesh\mesh\resmgr.h(8) : warning C4786: 'std::reverse_bidirectional_iterator<std::_Tree<short,std::pair<short const ,Handle<BaseResource> >,std::map<short,Handle<BaseResource>,std::less<short>,std::allocator<Handle< BaseResource> > >::_Kf n,std::less<short>,std::allocator<Handle<BaseResource> > >::iterator,std::pair<short const ,Handle<BaseResource> >,std::pair<short const ,Handle<BaseResource> > &,std::pair<short const ,Handle<BaseResource> > *,int>' : identifier was truncated to '2 55' characters in the debug information n:\game\0,01\mesh\mesh\resmgr.h(8) : warning C4786: 'std::reverse_bidirectional_iterator<std::_Tree<short,std::pair<short const ,Handle<BaseResource> >,std::map<short,Handle<BaseResource>,std::less<short>,std::allocator<Handle< BaseResource> > >::_Kf n,std::less<short>,std::allocator<Handle<BaseResource> > >::const_iterator,std::pair<short const ,Handle<BaseResource> >,std::pair<short const ,Handle<BaseResource> > const &,std::pair<short const ,Handle<BaseResource> > const *,int>' : identifier w as truncated to '255' characters in the debug information n:\game\0,01\mesh\mesh\resmgr.h(8) : warning C4786: 'std::pair<std::_Tree<short,std::pair<short const ,Handle<BaseResource> >,std::map<short,Handle<BaseResource>,std::less<short>,std::allocator<Handle< BaseResource> > >::_Kfn,std::less<short>,std::al locator<Handle<BaseResource> > >::iterator,std::_Tree<short,std::pair<short const ,Handle<BaseResource> >,std::map<short,Handle<BaseResource>,std::less<short>,std::allocator<Handle< BaseResource> > >::_Kfn,std::less<short>,std::allocator<Handle<BaseR esource> > >::iterator>' : identifier was truncated to '255' characters in the debug information n:\game\0,01\mesh\mesh\resmgr.h(8) : warning C4786: 'std::pair<std::_Tree<short,std::pair<short const ,Handle<BaseResource> >,std::map<short,Handle<BaseResource>,std::less<short>,std::allocator<Handle< BaseResource> > >::_Kfn,std::less<short>,std::al locator<Handle<BaseResource> > >::const_iterator,std::_Tree<short,std::pair<short const ,Handle<BaseResource> >,std::map<short,Handle<BaseResource>,std::less<short>,std::allocator<Handle< BaseResource> > >::_Kfn,std::less<short>,std::allocator<Handle <BaseResource> > >::const_iterator>' : identifier was truncated to '255' characters in the debug information Linking... MESH.exe - 0 error(s), 4 warning(s)
tymi warningami sie nie przejmuj, po prostu je wylacz
tymi warningami sie nie przejmuj, po prostu je wylacz
nie, przeczytaj tresc tych ostrzezen, to bedziesz wiedzial, ze nie musisz sie nimi w ogole przejmowac :) jak skompilujesz w RELEASE to ich nie bedzie
zanotowane.pl doc.pisz.pl pdf.pisz.pl zsf.htw.pl
Sory za takie pytanie, ale sam probowalem i nie moglem sobie poradzic z problemem. To jest kod przepisany z "Perełek Programowania Gier Tom 1." z rozdziału o uchwytach. Na początku sam próbowałem, ale też był ten błąd, aż w końcu przepisałem wszystko dokładnie z książki i błąd dalej istniał ten sam.
template <typename TAG> class Handle { union { enum { // rozmiary pól w bitach MAX_BITS_INDEX = 16; MAX_BITS_MAGIC = 16; // Maksymalne wartości pól. Przydadzą się w instrukcjach assert; MAX_INDEX = ( 1 << MAX_BITS_INDEX) - 1; MAX_MAGIC = ( 1 << MAX_BITS_MAGIC) - 1; }; struct { unsigned m_Index : MAX_BITS_INDEX; // index tablicy zasobów unsigned m_Magic : MAX_BITS_MAGIC; // magiczna liczba dotycząca // testowania }; unsigned int m_Handle; }; public: // Inicjalizacja Handle( void ) : m_Handle( 0 ) { } void Init( unsigned int index ); // Zapytania. unsigned int GetIndex ( void ) const { return ( m_Index ); } unsigned int GetMagic ( void ) const { return ( m_Magic ); } unsigned int GetHandle( void ) const { return ( m_Handle ); } bool IsNull ( void ) const { return ( !m_Handle ); } operator unsigned int ( void ) const { return ( m_Handle ); } };
oto co wyświetla kompilator
error C2065: 'MAX_BITS_MAGIC' : undeclared identifier see reference to class template instantiation 'Handle<TAG>' being compiled error C2149: 'm_Magic' : named bit field cannot have zero width see reference to class template instantiation 'Handle<TAG>' being compiled
Z góry dziękuje za wszystkie odpowiedzi :)

Wartości w enumie odziela się przecinkami, a nie średnikami

znowu pewnie zrobilem glupi blad(program sie kompiluje ale wyswietla sie mnustwo ostrzezen)
#include <map> #include <algorithm> typedef unsigned short u16; typedef Handle<BaseResource> hRes; typedef std::map<u16,hRes> ResMap; typedef ResMap::iterator ResMapItor;
Czy widzicie tu blad/niescislosc ?
jakby ktos potrzebowal moge podac te ostrzezenia ale jest ich troche duzo
typedef Handle<BaseResource> hRes;
co to jest Handle ?
co to jest Handle ?

Moze jednak pokaz te warningi, bo to jest teraz taki toto lotek :P
Moze jednak pokaz te warningi, bo to jest teraz taki toto lotek :P

Nieco powalone to chyba jest, bo po zmienieniu 'unsigned' na 'signed' warningow jest tylko 4
typedef signed short s16; typedef Handle<BaseResource> hRes; typedef std::map<s16,hRes> ResMap; typedef ResMap::iterator ResMapItor;
--------------------Configuration: MESH - Win32 Debug-------------------- Compiling... winmain.cpp n:\game\0,01\mesh\mesh\resmgr.h(8) : warning C4786: 'std::reverse_bidirectional_iterator<std::_Tree<short,std::pair<short const ,Handle<BaseResource> >,std::map<short,Handle<BaseResource>,std::less<short>,std::allocator<Handle< BaseResource> > >::_Kf n,std::less<short>,std::allocator<Handle<BaseResource> > >::iterator,std::pair<short const ,Handle<BaseResource> >,std::pair<short const ,Handle<BaseResource> > &,std::pair<short const ,Handle<BaseResource> > *,int>' : identifier was truncated to '2 55' characters in the debug information n:\game\0,01\mesh\mesh\resmgr.h(8) : warning C4786: 'std::reverse_bidirectional_iterator<std::_Tree<short,std::pair<short const ,Handle<BaseResource> >,std::map<short,Handle<BaseResource>,std::less<short>,std::allocator<Handle< BaseResource> > >::_Kf n,std::less<short>,std::allocator<Handle<BaseResource> > >::const_iterator,std::pair<short const ,Handle<BaseResource> >,std::pair<short const ,Handle<BaseResource> > const &,std::pair<short const ,Handle<BaseResource> > const *,int>' : identifier w as truncated to '255' characters in the debug information n:\game\0,01\mesh\mesh\resmgr.h(8) : warning C4786: 'std::pair<std::_Tree<short,std::pair<short const ,Handle<BaseResource> >,std::map<short,Handle<BaseResource>,std::less<short>,std::allocator<Handle< BaseResource> > >::_Kfn,std::less<short>,std::al locator<Handle<BaseResource> > >::iterator,std::_Tree<short,std::pair<short const ,Handle<BaseResource> >,std::map<short,Handle<BaseResource>,std::less<short>,std::allocator<Handle< BaseResource> > >::_Kfn,std::less<short>,std::allocator<Handle<BaseR esource> > >::iterator>' : identifier was truncated to '255' characters in the debug information n:\game\0,01\mesh\mesh\resmgr.h(8) : warning C4786: 'std::pair<std::_Tree<short,std::pair<short const ,Handle<BaseResource> >,std::map<short,Handle<BaseResource>,std::less<short>,std::allocator<Handle< BaseResource> > >::_Kfn,std::less<short>,std::al locator<Handle<BaseResource> > >::const_iterator,std::_Tree<short,std::pair<short const ,Handle<BaseResource> >,std::map<short,Handle<BaseResource>,std::less<short>,std::allocator<Handle< BaseResource> > >::_Kfn,std::less<short>,std::allocator<Handle <BaseResource> > >::const_iterator>' : identifier was truncated to '255' characters in the debug information Linking... MESH.exe - 0 error(s), 4 warning(s)
tymi warningami sie nie przejmuj, po prostu je wylacz
tymi warningami sie nie przejmuj, po prostu je wylacz

nie, przeczytaj tresc tych ostrzezen, to bedziesz wiedzial, ze nie musisz sie nimi w ogole przejmowac :) jak skompilujesz w RELEASE to ich nie bedzie