rijo / dus Goto Github PK
View Code? Open in Web Editor NEW[c++] Console tool to summarize directory usage (improved GNU's `du -s`)
License: GNU General Public License v3.0
[c++] Console tool to summarize directory usage (improved GNU's `du -s`)
License: GNU General Public License v3.0
The souce compiles using gcc-4.9 and gcc-5.3, but it won't compile using clang-3.7:
$ CXX=clang make
clang -std=c++14 -Wall -Werror -lpthread src/main.cpp -o dus
In file included from src/main.cpp:2:
In file included from src/fs.hpp:4:
In file included from /usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/5.3.0/../../../../include/c++/5.3.0/string:40:
In file included from /usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/5.3.0/../../../../include/c++/5.3.0/bits/char_traits.h:39:
In file included from /usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/5.3.0/../../../../include/c++/5.3.0/bits/stl_algobase.h:71:
/usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/5.3.0/../../../../include/c++/5.3.0/bits/predefined_ops.h:123:31: error: indirection requires pointer operand
('fs::file_info' invalid)
{ return bool(_M_comp(*__it1, *__it2)); }
^~~~~~
/usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/5.3.0/../../../../include/c++/5.3.0/functional:1981:27: note: in instantiation of function template specialization
'__gnu_cxx::__ops::_Iter_comp_iter<std::function<bool (const fs::file_info &, const fs::file_info &)> >::operator()<fs::file_info, fs::file_info>' requested here
using _Invoke = decltype(__callable_functor(std::declval<_Functor&>())
^
/usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/5.3.0/../../../../include/c++/5.3.0/functional:1990:2: note: in instantiation of template type alias '_Invoke' requested here
using _Callable
^
/usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/5.3.0/../../../../include/c++/5.3.0/functional:2057:30: note: in instantiation of template type alias '_Callable' requested here
typename = _Requires<_Callable<_Functor>, void>>
^
/usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/5.3.0/../../../../include/c++/5.3.0/functional:2058:2: note: in instantiation of default argument for
'function<__gnu_cxx::__ops::_Iter_comp_iter<std::function<bool (const fs::file_info &, const fs::file_info &)> > >' required here
function(_Functor);
^~~~~~~~
/usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/5.3.0/../../../../include/c++/5.3.0/bits/predefined_ops.h:130:14: note: while substituting deduced template arguments into
function template 'function' [with _Functor = __gnu_cxx::__ops::_Iter_comp_iter<std::function<bool (const fs::file_info &, const fs::file_info &)> >, $1 = (no value)]
{ return _Iter_comp_iter<_Compare>(__comp); }
^
/usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/5.3.0/../../../../include/c++/5.3.0/bits/stl_algo.h:4729:54: note: in instantiation of function template specialization
'__gnu_cxx::__ops::__iter_comp_iter<std::function<bool (const fs::file_info &, const fs::file_info &)> >' requested here
std::__sort(__first, __last, __gnu_cxx::__ops::__iter_comp_iter(__comp));
^
src/main.cpp:275:10: note: in instantiation of function template specialization 'std::sort<__gnu_cxx::__normal_iterator<fs::file_info *, std::vector<fs::file_info,
std::allocator<fs::file_info> > >, std::function<bool (const fs::file_info &, const fs::file_info &)> >' requested here
std::sort(files.begin(), files.end(), comparators[order_by]);
^
1 error generated.
Makefile:19: recipe for target 'dus' failed
make: *** [dus] Error 1
System: Ubuntu 15.10, gcc 5.2.1-22ubuntu2.
$ make
g++ -std=c++14 -Wall -Werror -Wextra -Wpedantic -Wshadow -lpthread src/main.cpp -o dus
/tmp/ccsK6DnM.o: In function `std::thread::thread<std::__future_base::_Async_state_impl<std::_Bind_simple<main::{lambda()#1} ()>, std::vector<fs::file_info_t, std::allocator<fs> > >::_Async_state_impl(main::{lambda()#1} (&&)())::{lambda()#1}>(std::__future_base::_Async_state_impl<std::_Bind_simple<main::{lambda()#1} ()>, std::vector<fs::file_info_t, std::allocator<fs> > >::_Async_state_impl(main::{lambda()#1} (&&)())::{lambda()#1}&&)':
main.cpp:(.text+0x9d6d): undefined reference to `pthread_create'
collect2: error: ld returned 1 exit status
Makefile:19: recipe for target 'dus' failed
make: *** [dus] Error 1
Solution: Use -pthread
instead of -lpthread
(at least in gcc; I haven't tried clang/llvm).
And, well, since since that flag sets more than just the library, strictly speaking it is not part of LDLIBS
anymore. ;)
`[dus] (master) $git rev-parse HEAD
b6ff3d9
[dus] (master) $g++ --version
g++ (GCC) 7.1.1 20170516
Copyright © 2017 Free Software Foundation, Inc.
Detta är fri programvara, se källkoden för kopieringsvillkor. Det
finns INGEN garanti, inte ens för KÖP eller LÄMPLIGHET FÖR NÅGOT
SPECIELLT ÄNDAMÅL.
[dus] (master) $make
g++ -std=c++14 -Wall -Werror -Wextra -Wpedantic -Wshadow -pthread src/main.cpp -o dus
In file included from src/main.cpp:4:0:
src/console.hpp: I funktion ”const std::vectorconsole::arg_t console::parse_args(int, const char**)”:
src/console.hpp:272:39: fel: denna sats kan falla igenom [-Werror=implicit-fallthrough=]
args.emplace_back(arg_t{arg, "", nullptr});
^~~~~~~~~~~~~~~~~~~~~~~
src/console.hpp:273:17: anm: här
case 0:
^~~~
cc1plus: alla varningar behandlas som fel
make: *** [Makefile:19: dus] Fel 1`
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.