{"id":140,"date":"2006-11-04T19:37:27","date_gmt":"2006-11-05T00:37:27","guid":{"rendered":"http:\/\/bitpost.com\/news\/2006\/11\/04\/moving-to-vc-8\/"},"modified":"2007-01-08T13:28:28","modified_gmt":"2007-01-08T18:28:28","slug":"moving-to-vc-8","status":"publish","type":"post","link":"https:\/\/bitpost.com\/news\/2006\/moving-to-vc-8\/","title":{"rendered":"Moving to VC++ 8"},"content":{"rendered":"<p>I used to use all the beta Microsoft products, now I find it more efficient to move up when I&#8217;m ready &#8211; and when things have matured.  However, a look at the boost regression tests shows that VC7.1 support is getting a bit lean, at least for the serialization library I use.  So&#8230; time to move on up.  Here is how the upgrade from 7.1 to 8.0 went for my HangTheDJ project&#8230;<!--more--><\/p>\n<p><strong>INSTALLATION<\/strong><\/p>\n<ul>\n<li>First, vc8 installation.  No problems.<\/li>\n<li>Downloaded latest Platform SDK, installed no problems.<\/li>\n<li>Wiped out boost and grabbed a fresh snapshot from cvs.<\/li>\n<li>Built boost for vc8.0, no problems.<\/li>\n<li>Added boost library path to Visual Studio Tools->Options->Projects and Solutions->VC++ directories<\/li>\n<li>Opened my HangTheDJ project and let Visual Studio convert it &#8220;in-place&#8221;.<\/li>\n<li>Added _CRT_SECURE_NO_DEPRECATE to Project->Properties->Config->C++->Preprocesor definitions.  Otherwise Microsoft prevents use of &#8220;unsafe&#8221; functions like strncpy.  There are better ways but I&#8217;m not rewriting all my legacy code just right this moment.  Besides, my code is generally fine, it&#8217;s boost and other shared code that more often plays it loose.  USE A STRING CLASS, PEOPLE!  :><\/li>\n<li>More recently, I updated Visual Studio with SP1.  Unfortunately I ran out of hard drive space in the middle and it made sort of a mess of things.  Finally reinstalled\/repaired enough times to make it happy.  It can take a long time.  Most annoyingly, make sure you have a couple GB of space on C:\\, even if you&#8217;re not installing there, to keep the installation happy.<\/li>\n<\/ul>\n<p><strong>COMPILATION ISSUES<\/strong><\/p>\n<ul>\n<li><strong>27 errors, 2 warnings<\/strong>, not bad&#8230;<\/li>\n<li>Looks like Microsoft finally got <em>for<\/em> loop variable scoping correct &#8211; if defined in the <em>for<\/em> statement, the variable is now scoped inside the braces.  So fix any related sloppy coding.<\/li>\n<li>The <em>pow()<\/em> function has new overloads, have to specify types correctly.<\/li>\n<li>Slightly stronger type checking &#8211; e.g., a <em>time_t<\/em> is not an <em>int<\/em>.<\/li>\n<li>Default behavior bad.  &#8220;<em>C++ does not support default-int<\/em>&#8221; &#8211; anymore!  Fix any crufty code that made the assumption.<\/li>\n<li>Some macros (like ON_WM_NCHITTEST) were updated to provide the &#8220;correct&#8221; (signed) return type, breaking a lot of (often wizard-generated) code.  This is the only upgrade hiccup of any significance, and it&#8217;s really trivial (albeit annoying) to fix.  Explanation is <a href=\"http:\/\/forums.microsoft.com\/msdn\/ShowPost.aspx?PostID=8663\">here.<\/a><\/li>\n<li><strong>HangTheDJ &#8211; 0 error(s), 0 warning(s)<\/strong>.  Upwards and onwards.<\/li>\n<\/ul>\n<p><strong>CODE GENERATION ISSUES<\/strong><\/p>\n<ul>\n<li>The actual code generated by VC8 is stricter.  I ran into the _SCL_SECURE_VALIDATE_RANGE macro, which asserted when I decremented an iterator below the start of a vector.  Why is that a crime?  Oh well, I rewrote the code to avoid going outside of the vector range, and everything is humming along now.<\/li>\n<li>Lots more debugger checking, and it seems sane for the most part.  I found one place where I actually referenced an iterator below the legal boundary, whoops.  Fixed.  Nice.<\/li>\n<li>VC8 is stricter about successfully dynamic_cast&#8217;ing.  The standard way of dealing with slider control changes is to process OnHScroll() messages in the parent dialog.  You get a pointer to a CScrollBar, which is crap, since it actually points to a CSliderCtrl class.  Now for the VC8 change: a dynamic_cast<> will FAIL if you don&#8217;t static cast to CSliderCtrl* BEFORE trying to dynamic_cast to a CSliderCtrl-derived class.  Funny, M$&#8217;s improved compiler is exposing the crappiness of their original design.  Code should look something like this:\n<div class=code>\nListDataByteSlider* pSlider = dynamic_cast< ListDataByteSlider* > ( (CSliderCtrl*)pScrollBar );<br \/>\nif ( pSlider )<br \/>\n  (it&#8217;s a message for your slider, do what you need to do&#8230;)\n<\/div>\n<\/li>\n<\/ul>\n<p><strong>IDE ISSUES<\/strong><\/p>\n<p>The most tweakable IU yet, the only real complaint is the amount of time to get it just right.<\/p>\n<ul>\n<li>The new Ctrl-Tab &#8220;NextDocumentWindowNav&#8221; behavior (which gives you a temporary list of all files, right in the middle of the screen) is obnoxious and distracting, IMHO.  Revert to the more-standard behavior of actually switching to the next file by reassigning the Ctrl-Tab keystroke (and Ctrl-Shift-Tab, of course) from Window.NextDocumentWindowNav to Window.NextDocumentWindow.<\/li>\n<\/ul>\n<p>Having fun with it now.  Microsoft has definitely been improving its compiler.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I used to use all the beta Microsoft products, now I find it more efficient to move up when I&#8217;m ready &#8211; and when things have matured. However, a look at the boost regression tests shows that VC7.1 support is getting a bit lean, at least for the serialization library I use. So&#8230; time to [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"enabled":false},"version":2}},"categories":[7,4,10,6],"tags":[],"class_list":["post-140","post","type-post","status-publish","format-standard","hentry","category-hangthedj","category-projects","category-tricks-tips-tools","category-windows-projects"],"aioseo_notices":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p9M11L-2g","jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/bitpost.com\/news\/wp-json\/wp\/v2\/posts\/140","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/bitpost.com\/news\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bitpost.com\/news\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bitpost.com\/news\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/bitpost.com\/news\/wp-json\/wp\/v2\/comments?post=140"}],"version-history":[{"count":0,"href":"https:\/\/bitpost.com\/news\/wp-json\/wp\/v2\/posts\/140\/revisions"}],"wp:attachment":[{"href":"https:\/\/bitpost.com\/news\/wp-json\/wp\/v2\/media?parent=140"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bitpost.com\/news\/wp-json\/wp\/v2\/categories?post=140"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bitpost.com\/news\/wp-json\/wp\/v2\/tags?post=140"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}