XCode tip-o-the-day

I've lived in Visual Studio since before it was a 1.0 product, yes, that's a very long time. Since coming to the Mac I've been spending more and more time inside XCode, very nice IDE by the way. The only downside is my fingers are trained to do Visual Studio keyboard shortcuts.

Well today one such key combination actually paid off.

If you do Alt+Shift+Mouse Down+Drag XCode column selects! Two thumbs way up guys! I don't know about you but I use that feature all the time!

Thanks XCode, you just saved me a bunch of time.

Labels: , , ,

Posted by Rob at 2:08 PM | 0 comments | Click here for a permalink to this entry.

Breaking on a memory allocation

I keep forgetting to write this down, so it's going on the good ole weblog for searching later.

If you have your code setup to do heap allocation tracking, _CTRDBG_LEAK_CHECK_DF and you'd like to break on a specific allocation, here's what you do once you've started debugging.

Add the following to the watch window.


Set the value to the allocation you'd like to break on. Now, if you're using the multi-threaded DLL runtime you'll have to provide a better context to the debugger. Like this.


So, if I'd like to see who allocated a hunk of memory, they were the 1000th caller, and they didn't free said memory, set the value to 1000, and the debugger will stop on allocation 1000.

Handy, big time handy.

Article on MSDN with more details, How to: Set Breakpoints on a Memory Allocation Number.

Labels: , , , , , ,

Posted by Rob at 1:48 PM | 0 comments | Click here for a permalink to this entry.

The web is not anywhere near the desktop

Duct Tape, fixer of all things!Ted Patrick: "Today MindJet launched MindManager Web, the online version of the popular mind mapping software. What is cool about it is that it has an identical look and feel to the original MindManager. Actually it makes me wonder when they replace the desktop version with an AIR app." - I don't get it when people think they can fully replace desktop apps with web apps, even if they're written in Flash/AIR, which is kind of cheating because you're running in a runtime, inside the browser, on the desktop. There are certain things the web is good for, there are other things it cannot replace. A drawing application, especially a really good one, is going to be tough to replace.

Having said that I think the web is great for services and it's super nice when the desktop application can be enhanced by a web service. We did this at Visio with the Find Shape feature. A web service for locating, and downloading, shapes from the web, into the desktop application. It worked quite well and gave you all the power and control of the desktop application.

Web only apps are still not there as a 100% replacement for the desktop, or client applications. Why do you think we have an iPhone SDK? Folks just couldn't do everything they wanted in the browser.

From what I know about AIR it has extreme limitations, some will see those limitations as a feature, which is true in some senses. If you have a HUGE investment in reusable frameworks, you cannot easily reuse those frameworks inside the AIR sandbox. That, for me, is a show stopper, which is quite unfortunate because it could be a great competitor to Microsoft's .NET if only you could reuse code more easily. Love or hate 'em, Microsoft has always done a great job of bringing old code into their new worlds. We've been able to bring critical frameworks into .NET very easily, and they behave like great .NET citizens.

Labels: , , , , , ,

Posted by Rob at 11:30 AM | 1 comments | Click here for a permalink to this entry.

Is it AIR, Flash, Flex, ActionScript?

The Flash Blog: "Ok so those are some of the words that will take on new definitions. There are also terms that will either change or go away completely. For instance, what should I say when I want to refer to the Flash authoring tool? Well stay tuned from Adobe on that one. For now I will specifically either say the version, as in Flash CS4, or just call it Flash authoring. As you may have heard from various sources, Flex Builder may soon be undergoing a name change. This makes total sense as the IDE is used for much more than just developing for the Flex framework. Stay tuned as we continue to roll out new pieces of the Flash Platform re-branding effort." - I've got to be honest and say, this is super confusing. On .NET Microsoft has done a good job separating terms. The CLR is the runtime , it is the machine. The .NET Framework is, well, the framework you build on top of; access to the OS, Collections, etc. Language terms are clear, we have C#, VB.Net, IronPython, IronRuby, and a host of other languages. We also have an IDE called Visual Studio.

So I could say "I built that on .NET, using C#, and Visual Studio". I have no idea how you describe that in the Adobe AIR/Flex/Flash/ActionScript world?

Would it be "I built that on AIR, using ActionScript, and the Flex IDE.", or something else all together?

I've been mixing AIR and Flex to mean the scripting language all week. I'm fairly certain AIR is equal to the .NET CLR?

Oh, and where does AIR fit into "Flash is being redefined?"

Hopefully we'll get some clear terms from Adobe soon, then maybe my pea brain can understand how everything works together.

Labels: , , , ,

Posted by Rob at 9:52 AM | 2 comments | Click here for a permalink to this entry.

More Visual Studio 2008 ick

I love Visual Studio. I need a little badge I can wear around that says "I (heart) Visual Studio!" I do, I really, really do. But... and there's always a but isn't there?

The latest release seems to have really gone the wrong direction for the C/C++ developer, in my humble opinion. Editing, debugging, all great. The problem seems to lie in the auto completion/browsing capability. It's horribly slow. This morning, after 30-minutes, I finally had to kill off Visual Studio after right-clicking so I could "Go to Definition" of a method. Yes, I had other stuff to do so I left it alone hoping to come back and the hour glass disappear so I could work, no luck. Nuke it.

So, here I sit, waiting on a build to complete, and I make the mistake of right clicking on method name again. The IDE is now out to lunch, sorry Rob, no right mouse clicks for you, and you can forget ever seeing that menu you'd like to see.

Thing is I'll bet the C#, and Visual Basic crowd, are pretty pleased with it. All those nice little pop-up tool-tippy style helpers that allow you to dig into objects to inspect their values is pretty darned nice. Too bad it comes at the expense of the C/C++ side of the equation.

Maybe, just maybe, there are some settings I'm not aware of that will allow me to get better responsiveness from the bits I do like? I'll need to dig around and see if I can turn off some stuff to improve performance.

PS, I wonder, if the DNA of Visual Studio has a built in defense mechanism that causes it to misbehave in a VM on a Mac? It could happen...

PPS, it's still better than Vi, emacs, and gdb on Linux. Heaven forbid I have to work in that all day, every day.

PPPS, Note to the Linux world. Check out the great job the XCode guys did on their IDE. It uses gdb under the hood and allows you different views of the debugger, gdb console view and a nice GUI view that allows you to set breakpoints interactively.

PPPPS, I need to look at KDevelop again. Maybe it's much better than I give it credit for.

Labels: , , ,

Posted by Rob at 8:49 AM | 1 comments | Click here for a permalink to this entry.

Debugging: C++ Templates, Brekpoints, and Visual Studio

A good friend, and co-worker Tom, has been on a Linux trip lately, which isn't a bad thing since we do create products that run on Linux. I've been giving him a bad time lately about his newfound love of Vi, and now he's getting into gdb, God help us.

Yesterday Tom posted some very useful tips for debugging templates in gdb, thanks Tom, but man, can it get any more arcane?

In honor of Tom's hard work I thought I'd share the same tip, only mine will be for those of you using Visual Studio.

1) Locate the line of code you'd like to debug.
2) Left-Mouse click in the left 'gutter', the grey strip that runs down the left of your edit window.
3) Press F5, or select Debug > Start Debugging.
4) Wait to hit the breakpoint.

Happy Debugging! Smile, life is good!

Favorite Linux debugging tip (not): "Just add some printf's to it"

Labels: ,

Posted by Rob at 10:05 AM | 0 comments | Click here for a permalink to this entry.

Visual Studio 2008 lesson

Wow, I just ran into a really freaky behavior in Visual Studio 2008. I'd set the Configuration Properties > C/C++ > Output Files > Object File Name to a custom path, and I forgot to include the trailing backslash, which caused me all kinds of grief.

Instead of
Basically the compiler happily created one file with the same name over and over and over and was actually able to successfully link, not sure why that worked, but it did.

So when I went to link to this particular library I'd get a whole mess of unresolved external references.

I finally saw my problem this morning. So, word to the wise, remember the trailing backslash. Yes, this was a user error, but it was sure very easy to make that mistake.

Labels: , ,

Posted by Rob at 7:45 AM | 1 comments | Click here for a permalink to this entry.

Strange behavior, a fix

Watch out! It's a blog fly!I've figured out my problem from last night, so I thought I'd share with everybody, just in case you run across it.

First off here's my configuration, it plays heavily into the problem.

1) MacBook Pro
2) VMWare Fusion
3) Windows XP, running in VM
4) Shared fold on Mac for source code
5) Visual Studio 2008
6) Trolltech Qt

The big cluprit, the shared folder on the Mac. For some strange reason Visual Studio will lose its' brain after a while and can no longer write to .IDB/.PDB files on the HPFS volume. There's a lot going on in there, so it could be anything causing the problem. Anywho, to fix my problem I made sure all intermediate and binary files are being written to my XP volume, not the shared drive. It was easy to fix because we use environment variables to direct Visual Studio to the root of our codebases and where to write intermediate and finished binary files, there was one little problem. We auto generate our Visual Studio project files using a program, from Trolltech, called qmake. It's part of Qt, and is quite handy, but in this case it requires a small 'fix' to get around this problem.

By default qmake sets C/C++ > Output Files > Program Database File Name to '.', which in my case would write the .IDB/.PDB files to the shared Mac volume, which causes the strange behavior. No worries! We have the source code to qmake, so you need to make the following change to 'fix' this problem.

Open the file msvc_vcproj.cpp from \Qt\4.4.0\qmake\generators\win32, in the method initCompilerTool(), line 988 in Qt 4.4.0.

Change this...
conf.compiler.ProgramDataBaseFileName = ".\\" ;
To this...
conf.compiler.ProgramDataBaseFileName = placement;
Rebuild qmake, and run qmake over your project files. That should help.

The real fix is this, do not build to your shared Mac drive, there's some sort of caching/permissions problem with it.

Oh, here's the original problem.
fatal error C1090: PDB API call failed, error code '23' : '(
And all you Open Source zealots, please don't point out we have the code. We paid for it, and if they were shipping a binary only version they wouldn't have hard coded these settings. They would've been configurable, so I wouldn't have had to touch the code.

Labels: , , , ,

Posted by Rob at 12:49 PM | 0 comments | Click here for a permalink to this entry.

That's a new one?

Recently we upgraded from Visual Studio 2003 to Visual Studio 2008 for our Windows products and I've been having one heckuva time trying to build. I keep getting the following error...

fatal error C1090: PDB API call failed, error code '23' : '(

One interesting hit on Google produces this, a bug report marked as By Design. If you look in the comments for the report you'll see two comments saying it's still around. Why, yes, yes it is, and I'm experiencing it.

Hopefully I'll be able to find a workaround, or a fix for it, and soon. It's strange it's only happening for this one particular codebase, I've been building other things with Visual Studio 2008 for a while now, without issue.

Time to dig around a bit.

Labels: ,

Posted by Rob at 9:50 PM | 0 comments | Click here for a permalink to this entry.

Visual Studio Command Window

Sara Ford: "To create an alias, open up the Command Window (or anywhere you can type in VS commands) and type in something along the lines of..." - I've always wondered how to use the Command Window, but I've never taken the time to look into it, much less use it. I love the the alias "?", shades of Classic Visual Basic.

Labels: , ,

Posted by Rob at 8:10 AM | 0 comments | Click here for a permalink to this entry.

Visual Studio Debugging Tip

Sara Ford: "if you double-click on any error or warning in the output window, you will jump directly to that location in the file (or the closest equivalent)" - Good tip. If you're interested in taking advantage of this sort of functionality in your own code, it's very easy.

Please note, the code below is very simplified, and for demonstration purposes only. You'd want to wrap this is a way that makes sense for your application. ATL and MFC provide this sort of stuff, but you can roll your own.
char buffer[MAX_PATH];
// Yes, I know this is an unsafe CRT call. :-)
sprintf(buffer, "%s(%d): Debug Message\n", __FILE__, __LINE__);
So what does that do? It will dump something similar the following to the Output window...

c:\yoursource\yourfile.cpp(99): Debug Message

Now if you follow Sara's tip it will jump you right to the code that dumped out the message.

Labels: , ,

Posted by Rob at 8:10 AM | 0 comments | Click here for a permalink to this entry.

Dynamic C#

Charlie Calvert: "All the code that occurs in a dynamic block will potentially support dynamic lookup; even if the accessed members are not known by the C# compiler to exist, it will allow the code." - Does C# have to become a kitchen sink language? Why not let IronRuby and IronPython become the leaders in this regard and keep C# as clean as possible? One of the arguments presented for the inclusion of dynamic support is that PIA's can be expensive. If someone needs to use a COM component generate an assembly in a language that supports dynamic lookup and use that.

C# doesn't need to be all things to all people.

Labels: , , ,

Posted by Rob at 2:20 PM | 0 comments | Click here for a permalink to this entry.

SQL Express Life Saver

Note to self: osql is a life saver.

2> GO
1> USE databasename
2> GO
1> EXEC sp_grantdbaccess 'MACHINENAME\ACCOUNT'
2> GO
1> exit

Helpful links:

ASP.Net Forums
MSDN Forums

Microsoft TechNet

These three links just saved me!

Labels: , , , ,

Posted by Rob at 2:33 PM | 0 comments | Click here for a permalink to this entry.

Visual Studio 2008

John Lam: "Well, lots of other folks beat me to the punch about the announcement, but I was busy installing the product yesterday :) It's a popular product *inside* the company as well, and it took about 5 hours to grab from our internal share ... You can grab trial copies from here, and you can download the free (Express) editions from here." - John also links to a poster for C# keybindings, some of us still use an old outdated language called C++, so here is the poster for C++ keybindings.

Labels: , ,

Posted by Rob at 7:49 AM | 0 comments | Click here for a permalink to this entry.


Rob Fahrni has been a Software Developer for 20 years. He's developed DOS, Windows, Linux, iPhone, and Palm based applications in C, C++, Objective-C/Cocoa, C#/ASP.Net, and, yes, even BASIC...
About >>

CrabApples.NET Home Kim Fahrni, Hacker Widow Haileigh Fahrni, My Culinary Journey Taylor Fahrni, Goin' Buggy Jerry Fahrni, Pharmacy Informatics and Technology

Apple Core Labs, LLC RxCalc - A Pharmacokinetic Calculator for iPhone


I work at Pelco. The opinions expressed here are my own, and neither Pelco nor any other party necessarily agrees with them.

Subscribe to ATC Send e-mail to Rob Follow me on Twitter. My Profile on LinkedIn.