NMSTL Installation Guide

by Jon Salz

NMSTL consists solely of header files. Since some people prefer STL-style all_lower_case format for class name, and others prefer MixedCaps format, we provide two versions. The nmstl directory declares classes in the nmstl namespace named like so:
namespace nmstl {
    class thread;
    class io_event_loop;
    class io_handler;
The NMSTL directory declares classes in the NMSTL namespace:
namespace NMSTL {
    class Thread;
    class IOEventLoop;
    class IOHandler;
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). Use
#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.)

wtf configure        or ./configure, if you're not using wtf)
make docs

Using WTF

From the Ten-minute Guide to NMSTL:
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:
../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>&(*)(std::basic_ostream<_CharT, _Traits>&)) [with _CharT =
   char, _Traits = std::char_traits<char>]
Oh, by the way, the last five lines are repeated about 25 times.

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:

../nmstl/thread:302:no match for `ostream& << my_thread&' operator
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.
Much nicer eh? You can find wtf in the bin directory of the distribution - I find it useful for nearly any C or C++ development.
Using WTF is totally optional, but here's how to install and use it if you like.

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:

  1. When you first configure your source tree, instead of typing 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.)
  2. Instead of typing make, type wtf make. (WTF will automatically be used to compile targets.)
  3. Preface your compilation commands with 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.
P.S. WTF stands for "Where's the Faux Pas?". Get your mind out of the gutter!