Monday, October 31, 2005

Holiday - and enjoy the cup!

And now I'm off! Heading down to Apollo Bay for a much-deserved week away with Melissa. I'll probably be incommunicado until Sunday. It'll be the longest I've unplugged for in aaaages. I won't know what to do with myself! ;)

And I'm scared to think how many blog postings I'll have waiting for me when I jump online again.

Have fun at - or watching - the Melbourne Cup folks!

VS2005 issues

In my last post I mentioned that VS2005 was tighter than its predecessor. I thought it'd be useful to show where we had some problems (we're still working through them so this isn't an exhaustive list) and some of our solutions.

The changes are all covered in detail in the MSDN document "Breaking Changes in the Visual C++ 2005 Compiler" but I'll try and give some real examples that we faced.

Pointer-to-members now require qualified name and &

The compiler is much stricter about the types of function pointers. The error C3867 is generated with the following code:

: m_MyObserver(this, MyCallback)
The resolution is to qualify the function pointers and pass the addressof the function in. e.g.
: m_MyObserver(this, &CAThing::MyCallback)

const_cast can't down cast / Previously implicit string
casts are no longer allowed

This code does not compile (error C2440)
   BSTR bstrMessage = SysAllocString(T2OLE(const_cast(MyThing.ErrorMessage.c_str())));
This was replaced with the following (the BSTR could be deallocated after use):
   CComBSTR bstrMessage(MyThing.ErrorMessage.c_str());
This code will also give the same error:
   OLECHAR* pStringBuffer;
USHORT* pString = pStringBuffer;

COM/C++ Attributes with enumeration values should not be enclosed in quotes.

This code:
Should be rewritten without the quotes as:
The first time that the quotes get compiled gives warning C4581. This implies that the double quotes (") need to be replaced with single quotes ('). However, if you do this you then get error C3455. This error will say that "none of the attribute constructors matched the arguments".

Public attributes are stricter

The error MIDL2072 will be emitted for this code:
    typedef [public] enum EEventIdType
} EEventIdType;
The solution is to place the public attribute earlier:
    [public] typedef enum EEventIdType

The scope of variables in control constructs is limited to
the construct

In this code:
    for (int i = 0; i*max  ;++i)

The scope of i is limited to the for loop. (The * is meant to be a less than operator but I'll be damned if I can get blogger to cooperate!)

Method declarations must explicitly indicate return types

This code gives the error C4430:
    virtual CheckChar(UINT maskChar, UINT nChar, int endPos);
The return type must be explicitly defined. e.g.
    virtual int CheckChar(UINT maskChar, UINT nChar, int endPos);

Private types are not accesible outside of the class they
are declared in

This code gives the error C2248:
    class cdxCSizingPropSheet : public CPropertySheet
struct StandardControls

static struct cdxCSizingPropSheet::StandardControls psheetCtrls[] =
In this example, the struct StandardControls needs to be available at the global scope for psheetCtrls.

Deprecated methods

For security, many methods/functions that can cause buffer overruns have been deprecated. The recommended action is:
  • replace the deprecated methods, or
  • define _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES as 1 so the compiler will use a template overload to replace the deprecated method with another. N.B. security template overloads are not available for everything. Alternatively,
  • define _CRT_SECURE_NO_DEPRECATE or the warning pragma to not display this warning.
If you want my opinion (sure you do!) any function that can cause buffer overruns ought to be an error and avoided. You'll thank me later. ;)

OK, that's it for now. We had a few more but I've had it with trying to lay out code in Blogger. Does anyone know any good blogging software to write code? It's damn hard from within the Blogger editor. I'm thinking of moving to my own system hosted at home for this reason alone (actually there are a few more!). If I was to move to my own system which can you recommend that do a good job of handling code?

Anyway, I hope that was useful to you - and a huge thanks to Ben who wrote most of this in our Wiki at work. The good work was his, the errors mine. :)

Friday, October 28, 2005

VS2005 and .NET is shipping!

The newest version of Miscrosoft's development suite - and the matching .NET framework - has just ben released to MSDN subscribers!

Kudo's to Geoff for watching so attentively. You may not have gotten the scoop buddy but you were the first person I saw that made the announcement. :)

Personally, our company will be making the switch (from VS2003) quite quickly, and I can't wait.

Beware though folks, if you're compiling C++ code you may have a fair chunk of work migrating. The compiler is significantly more strict and we've found many errors (and warnings) that have to be rectified. As a positive, remember that your code will be cleaner when you're finished!

Wednesday, October 26, 2005

Heading OS for awhile

My role at Agilent Technologies is soon going to change. On the 23rd of November I'll be heading off to San Jose, California to support our products at one of our largest customer sites. It's a six month assignment and I'm damn excited about it! :)

It's a pretty big change. For the past few years I've been a full-time software engineer, beavering away developing features for our product line. This new role is totally about support. It's unlikely that I'll write any code except perhaps for some automation scripts. That'll take some getting used to as I really enjoy writing code.

However, helping customers understand and solve problems with our products is a new challenge that I welcome. I've always believed that to be a really good software engineer you need to thoroughly understand your customers needs so this experience will be invaluable from that point of view.

And I'm really looking forward to spending time soaking in the California culture (alas not much of the sun - I'll be there through winter!) and seeing some of the sights.

The only really tough bit is that my amazing girlfriend Melissa won't be able to come with me. She'll be (hopefully) joining me for a month in the middle of the trip - which will be fantastic! - but we've hardly spent more than a couple of days apart, let alone months. Ugh, that's going to suck.

Baby, if you're reading this, I'm going to miss you like crazy.

Thank goodness for webcams, broadband connections and video chat. ;)

Anyway, I just wanted to give y'all a heads up to let you know that I won't be in the country for much longer. I'll also be starting up another blog to document my adventures over there - I'll post a link to it when I get around to creating it.

Thursday, October 20, 2005

Three links of potential goodness

My bookmarks folder is a mess and I've got a brazillion (hehe) tabs open in Firefox. So I figure why not post a couple of useful links here? You may even find them useful.

ShinyFeet is a site that advertises unlimited email and file storage. It's also got some sort of photo gallery feature. Don't yet know what the catch is (probably advertising).

YouSendIt is a cool site that allows you to send a file (up to a gig!) to someone. Here's how it works. Type in a recipient's email address. Upload a file. The file is stored temporarily (for about a week I think) on the YouSendIt server and a link to the file is sent to the recipient. Again, not sure of the gotcha (advertising again?) but it's a pretty nifty idea.

Inquisitor is a(nother) search engine but has AJAX goodness and searches as you type. Pretty sweet. It gathers it's results from Google.

Tuesday, October 04, 2005

Other blogs

Speaking of other blogs...I write in a couple now and just thought I'd quickly 'advertise' them.

Matts iPod News is a blog all about iPods and iPod accessories.

Wireless Cranium is my friend Jiggy's blog. Jiggy is a music buff and really knows his stuff - probably because he owns a pooload of CD's and spends all his spare time absorbed in the world of music. ;) I occasionally write in the blog since I also love listening to sweet, sweet music...

Photo Impression, as mentioned recently, will contain photography news and information as well as links to photos that Jarek (aka J-Man) or I like. It's only early days for this blog but we'll see where it goes...

Then there's this blog which I'm still, even after over a year, trying to figure out what to really do with. I'd like to write more articles on software development but damn they take some serious time that I just haven't had lately. Mostly it's just become a dumping ground for stuff I want to say, which is fine but probably terrible to read! Anyway, I'll try and sprinkle a few software-related posts in amongst the drivel. I hope you get something, even if it's only a tiny something, out of reading this blog!

Monday, October 03, 2005

Lens fixed, a 'new' camera and a new blog

Speaking of cameras...I'm sure you remember the heartache, the despair and the horror of the day my lens broke. Well, my 80-200 has come back from repair and it's better than new!

The wonderful folks at the Camera Clinic (no web site unfortunately) on Easey St in Collingwood did a fantastic job with the lens. Not only that but it was just a pleasure dealing with them - they kept me well informed, were sympathetic, spelt out my options and gave me a reasonable price. If you've got a problem with your camera gear I can highly recommend them.

Here's some (hastily taken) shots of my new and improved baby:

Note the general roundness. ;) I heart that lens. :)

The other bit of photograpy-related news is that I bought a 'new' camera. It's an old-school Yashica medium format TLR camera from the early 60's. No photos since I left it at work (maybe tomorrow!) but there is a shot of it in the eBay listing that I won.

I've been fascinated by all sorts of photographic equipment and I've wanted to play with a medium format cameras for years. I haven't run any film through this Yashica yet but, assuming it works properly (it makes all the right sounds though the shutter is a little suspect), I'm intrigued that this relic can produce better images than the most expensive, top-of-the-line digital SLR.

Maybe next up will be a large-format view camera, who knows!?

Finally, I'm going to try and minimise the photography-related posts to this blog from now on. I've set up a new blog, Photo Impression, solely for photography related news. My friend Jarek and I are keen hobbyist photographers and we'll endeavour to post links to photos we like and share any photography-related information. So if you're interested in cameras, lenses and striving to capture the perfect photo take a squiz or subscribe.

Geek Dinner this Friday

My mate Tejas has organised a geek dinner for this Friday at Gopal's vegetarian restaurant on Swanston st at 6:30.

Check out the details at Tejas' Blog.

My camera and I are going to make every effort to be there!