000
03.10.2006, 17:04 Uhr
PaRu
|
ich habe versucht eine stl-list mit einem boost path zu kombinieren. der quellcode sieht wie folgt aus:
C++: |
#include <list> #include <string> #include <iostream> #include "boost\filesystem\operations.hpp" namespace boostFS = boost::filesystem;
bool find_file( const boostFS::path& dir_path, const std::string& file_name, std::list<boostFS::path&> path_found ) { if ( !exists( dir_path ) ) return false; boostFS::directory_iterator end_itr; for ( boostFS::directory_iterator itr( dir_path ); itr != end_itr; ++itr ) { if ( is_directory( *itr ) ) { if ( find_file( *itr, file_name, path_found ) ) return true; } else if ( itr->leaf() == file_name ) { path_found.push_back(*itr); return true; } } return false; }
int main( int argc, char *argv[] ) { char fileTyp[] = "test.txt"; boostFS::path searchDir("./"); std::list <boostFS::path> pathsFound; std::list <int>::size_type length;
find_file(searchDir, fileTyp, pathsFound); length = pathsFound.size() std::cout << "Path:" << std::endl; for( int i = 0; i < (int)length; i++ ) { std::cout << (pathsFound.front()).string() << std::endl; pathsFound.pop_front(); } }
|
leider bekomme ich vom compiler folgende fehlermeldung, mit der ich aber leider nichts anfangen kann. ich mußte die fehlermeldung am ende, da sie zu lang zum posten war
Code: |
C:\Entwicklung\User\C-C++\Test>mingw32-make all g++ -Wall -I./src -I../../../Boost -MM src/main.cpp > src/main.dep g++ -Wall -I./src -I../../../Boost -c src/main.cpp -o src/main.o c:/Entwicklung/MinGW/bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/ext/new_allocator.h: In instantiation of `__gnu_cxx::new_allocator<boost::filesystem::path&>': c:/Entwicklung/MinGW/bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/bits/allocator.h:81: instantiated from `std::allocator<boost::filesystem::path&>' c:/Entwicklung/MinGW/bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/bits/stl_list.h:295: instantiated from `std::_List_base<boost::filesystem::path&, std::allocator<boost::filesystem::path&> >' c:/Entwicklung/MinGW/bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/bits/stl_list.h:388: instantiated from `std::list<boost::filesystem::path&, std::allocator<boost::filesystem::path&> >' src/main.cpp:9: instantiated from here c:/Entwicklung/MinGW/bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/ext/new_allocator.h:52: error: forming pointer to reference type `boost::filesystem::path&' c:/Entwicklung/MinGW/bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/ext/new_allocator.h:53: error: forming pointer to reference type `boost::filesystem::path&' c:/Entwicklung/MinGW/bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/ext/new_allocator.h:54: error: forming reference to reference type `boost::filesystem::path&' c:/Entwicklung/MinGW/bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/ext/new_allocator.h:55: error: forming reference to reference type `boost::filesystem::path&' c:/Entwicklung/MinGW/bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/ext/new_allocator.h:72: error: forming pointer to reference type `boost::filesystem::path&' c:/Entwicklung/MinGW/bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/ext/new_allocator.h:75: error: forming pointer to reference type `boost::filesystem::path&' c:/Entwicklung/MinGW/bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/ext/new_allocator.h:81: error: forming pointer to reference type `boost::filesystem::path&' c:/Entwicklung/MinGW/bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/ext/new_allocator.h:86: error: forming pointer to reference type `boost::filesystem::path&' c:/Entwicklung/MinGW/bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/ext/new_allocator.h:96: error: forming reference to reference type `boost::filesystem::path&' c:/Entwicklung/MinGW/bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/ext/new_allocator.h:99: error: forming pointer to reference type `boost::filesystem::path&' c:/Entwicklung/MinGW/bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/bits/allocator.h: In instantiation of `std::allocator<boost::filesystem::path&>': c:/Entwicklung/MinGW/bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/bits/stl_list.h:295: instantiated from `std::_List_base<boost::filesystem::path&, std::allocator<boost::filesystem::path&> >' c:/Entwicklung/MinGW/bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/bits/stl_list.h:388: instantiated from `std::list<boost::filesystem::path&, std::allocator<boost::filesystem::path&> >' src/main.cpp:9: instantiated from here c:/Entwicklung/MinGW/bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/bits/allocator.h:85: error: forming pointer to reference type `boost::filesystem::path&' c:/Entwicklung/MinGW/bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/bits/allocator.h:86: error: forming pointer to reference type `boost::filesystem::path&' c:/Entwicklung/MinGW/bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/bits/allocator.h:87: error: forming reference to reference type `boost::filesystem::path&' c:/Entwicklung/MinGW/bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/bits/allocator.h:88: error: forming reference to reference type `boost::filesystem::path&' c:/Entwicklung/MinGW/bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/bits/stl_list.h: In instantiation of `std::list<boost::filesystem::path&, std::allocator<boost::filesystem::path&> >': src/main.cpp:9: instantiated from here c:/Entwicklung/MinGW/bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/bits/stl_list.h:396: error: no type named `pointer' in `class std::allocator<boost::filesystem::path&>'
...
c:/Entwicklung/MinGW/bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/bits/stl_list.h:511: instantiated from `std::list<_Tp, _Alloc>::list(const std::list<_Tp, _Alloc>&) [with _Tp = boost::filesystem::path&, _Alloc = std::allocator<boost::filesystem::path&>]' src/main.cpp:17: instantiated from here c:/Entwicklung/MinGW/bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/bits/stl_list.h:1139: error: no match for 'operator*' in '*__first' c:/Entwicklung/MinGW/bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/bits/stl_list.h:1139: error: `_M_insert' undeclared (first use this function) c:/Entwicklung/MinGW/bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/bits/stl_list.h:1139: error: (Each undeclared identifier is reported only once for each function it appears in.) mingw32-make: *** [src/main.o] Error 1
|
-- Gruß Patrick |