by Jon Salz
nmstl
directory
declares classes in the nmstl
namespace named like so:
Thenamespace nmstl { class thread; class io_event_loop; class io_handler; };
NMSTL
directory declares classes in the NMSTL
namespace:
To use NMSTL, simply copy one or both of these directories into the include directory of your choice (or directly into your project tree if you prefer). Usenamespace NMSTL { class Thread; class IOEventLoop; class IOHandler; };
#include
<nmstl/whatever>
for the all_lower_case
version, or #include
<NMSTL/whatever>
for the MixedCase version.
N.B.: If you're working from the CVS tree, you'll need to type the following before installing. (Some of NMSTL is generated automatically by Perl scripts.)
autoconf wtf configure or ./configure, if you're not using wtf) make make docs
Working with template-heavy code like NMSTL and STL can involve some really weird-looking compiler errors. For instance, this is g++'s way of complaining politely that you forgot to define an operator << for your class:Using WTF is totally optional, but here's how to install and use it if you like.Oh, by the way, the last five lines are repeated about 25 times.../nmstl/thread: In copy constructor `nmstl::guard<Lock>::guard(const nmstl::guard<Lock>&) [with Lock = nmstl::mutex]': ../nmstl/seda:277: instantiated from here ../nmstl/thread:302: no match for `std::ostream& << nmstl::guard<nmstl::mutex>::my_thread&' operator /home/jsalz/gcc3/include/c++/3.2/bits/ostream.tcc:55: candidates are: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(std::basic_ostream<_CharT, _Traits>&(*)(std::basic_ostream<_CharT, _Traits>&)) [with _CharT = char, _Traits = std::char_traits<char>]Reading such error messages may leave you scratching your head, or perhaps standing on your chair yelling such phrases as "WTF?!!" (What's The Faux-pas?)
Anyone who has experienced this problem, which is to say anyone who uses STL, may want to take a look at "WTF", a little Perl hack which makes these error messages a lot more easily decipherable and gives you some context, like:
Much nicer eh? You can find../nmstl/thread:302:no match for `ostream& << my_thread&' operator 300> 301> my_thread t; 302> cout << t; 303> } 304> guard& operator = (const guard& g) { N.B.: You probably need to use an NMSTL_TO_STRING(my_thread); macro immediately following your class declaration for my_thread.wtf
in thebin
directory of the distribution - I find it useful for nearly any C or C++ development.
First of all copy the wtf
program from NMSTL's bin
into some directory in your path (/usr/local/bin
,
$HOME/bin
, etc.). Here are three alternate ways to use WTF (in order
of preference). Pick one:
configure
, type wtf configure
. Now every time you
use make
, WTF will automatically be used. (This method
is best because you only have to do it once! Also note that you don't
have to change any of your autoconf
configuration.)
make
, type wtf make
.
(WTF will automatically be used to compile targets.)
wtf
.
E.g., instead of typing:
g++ -c input.cc
type this:
wtf g++ -c input.cc
This gets kind of annoying since you have to remember to type it every
time, so I suggest method 1 or 2 instead.