Jul 26, '04 11:10:00AM • Contributed by: paco
The simplest fix is to find the tmac.vgrind file and put it in the right directory. As it is, the file exists but it's in the wrong place. So when vgrind invokes troff, it isn't found and vgrind fails. To fix it, run this command from a Terminal window:
Although that will get vgrind up and going it's not very good on C++ as is. There's another file called vgrindefs that tells vgrind how to recognize the syntax of various languages. I find that FreeBSD's vgrindefs file is better. I recommend downloading that file and copying it to /usr/share/misc. Here's how to do it from a Terminal window:
% sudo ln /usr/share/groff/tmac/tmac.vgrind /usr/share/groff/1.18.1/tmac/
% /usr/bin/ftp -o vgrindefs \ 'http://www.freebsd.org/cgi/cvsweb.cgi/~checkout~/src/\ usr.bin/vgrind/vgrindefs.src?content-type=text/plain' % sudo cp vgrindefs /usr/share/misc
To use vgrind, simply provide one or more code files on the command line. It spits out Postscript on standard out, meaning that you have to capture that output to a file. Then you probably want to convert it to PDF so that you can view it with Preview and print it. I do it this way in a Terminal window:
Now I can open wtf.pdf and print from Preview. Note that I used the ps2pdf command there. That's part of Ghostscript, which you can get easily using Fink Commander. In theory, Preview can convert Postscript to PDF, but I've never seen it do a credible job. It either takes forever or it just hangs.
% vgrind wtf.cc | ps2pdf - wtf.pdf
If you're interested, here's an example of some input and output:
- Keyword bolding
- Proportionately spaced fonts. (I find it easier to read, but it's a matter of opinion)
- The current function name is printed in the right-hand margin, and appears there from page to page if a function is split across multiple pages.
This particular example illustrates a bug in GCC that I found on the gcc mailing list. I've duplicated this behavior on Intel Linux (Fedora Core 1), but on no other platform. FreeBSD/AMD, OpenBSD Intel, MacOS X PPC, Solaris Sparc, etc. None exhibit this floating point issue. But that's beside the point...