Thursday, July 15, 2010

Worst Microsoft Dialogs

So, I thought this dialog was pretty bad:


I mean, the only question in all that text (you know, the sentence that ends in a question mark) is not a yes/no question.  The actual question is down at the bottom and ends in a nonsensical colon.  And it has not one, but two parenthetical phrases.  And it contains a really long, unwieldy URL that isn't clickable or copyable.

But then I got this gem from Windows Live Mail (in Windows 7) today:


First of all, I had pressed ALT+F4 to close WLM having completed my business with it.  Opening a modal dialog for something only tangentially related to exiting the app is a little intrusive, but, okay.  The thing that's really bad about this is that it tells me what won't happen if I click yes, but I still have no idea what will happen if I click yes.  But I only use WLM to read mail that comes to my passport account from Microsoft lists, so if it all gets deleted I don't really care.  So I'm feeling adventurous and click yes.  Then I get this:


Really?  You didn't see that one coming WLM?

Sigh.  The fight goes on.

Wednesday, March 24, 2010

Perforce has the best error messages.

I wanted to know what the path to something was on the server, but I couldn't remember. Little did I know that perforce would be so judgemental:

c:\source>p4 dirs *
//depot/foo/bar/baz
//depot/foo/bar/qux
Client map too twisted for directory list.

And then there was the time I made a perfectly reasonable request, I wanted to edit all the unittest files in the entire tree, and it had to go and get all preachy:

c:\source\v2-dev>p4 edit foo\...*unittest.cc
Senseless juxtaposition of wildcards in '//jeff-src/foo/...*unittest.cc'.

I mean, yeah, maybe there's a typo there, but you don't have to insult me.

Wednesday, March 17, 2010

GetModuleFileName() on OS X.

So, you want to know the path to your module.  On Windows, it's easy: you call GetModuleFileName() and pass NULL for the HMODULE.

But what if you're trying to do it on OS X?

#include <dlfcn.h>
std::string GetModuleFileNameOSX() {
  Dl_info module_info;
  if (dladdr(reinterpret_cast<void*>(GetModuleFileNameOSX), &module_info) == 0) {
    // Failed to find the symbol we asked for.
    return std::string();
  }
  return std::string(module_info.dli_fname);
}

For the first param to dladdr, you can pass any symbol you know will be in your module. In theory, something similar should work on linux, but I haven't tried.