<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Alteridem Consulting &#187; C++/CLR</title>
	<atom:link href="http://www.alteridem.net/category/net/cppclr/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.alteridem.net</link>
	<description>Software by Design</description>
	<lastBuildDate>Thu, 02 Sep 2010 17:52:37 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Debugging C++ Method Parameters</title>
		<link>http://www.alteridem.net/2007/09/11/debugging-c-method-parameters/</link>
		<comments>http://www.alteridem.net/2007/09/11/debugging-c-method-parameters/#comments</comments>
		<pubDate>Tue, 11 Sep 2007 19:20:04 +0000</pubDate>
		<dc:creator>Robert Prouse</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[C++/CLR]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://www.alteridem.net/2007/09/11/debugging-c-method-parameters/</guid>
		<description><![CDATA[New Rule: Make sure your parameter names are consistent between your declarations and definitions in C++. Here is why&#8230; I was trying to debug some C++/CLR code today when I ran into an interesting behavior (bug?) in Visual Studio 2005. I had a breakpoint in the first line of my method which I hit fine. [...]]]></description>
			<content:encoded><![CDATA[<p><strong>New Rule: Make sure your parameter names are consistent between your declarations and definitions in C++.</strong></p>
<p>Here is why&#8230;</p>
<p>I was trying to debug some <strong>C++/CLR</strong> code today when I ran into an interesting behavior (bug?) in <strong>Visual Studio 2005</strong>. I had a breakpoint in the first line of my method which I hit fine. I then tried to inspect the value of the two integers that were passed in. The first one showed up fine when I moused over it, but the second one didn&#8217;t appear. Strange, but I&#8217;ve come to expect that debugging in C++.</p>
<p>The next thing I tried was the Watch window (Ctrl+Alt+W,1). I added both of the parameters. The first showed up fine, but the second said <strong>&#8220;error: identifier &#8216;maxRows&#8217; out of scope.&#8221;</strong> How could it be out of scope, I was on the first line in the method?</p>
<p>Next I looked at the Locals window (Ctrl+Alt+V,L). The parameter was showing up fine there! Then I noticed the difference, the name of the parameter in the locals window wasn&#8217;t pluralized. Sure enough, I looked in the header file and it was spelled <strong>maxRow</strong> there.</p>
<p>It turns out that the debug symbols are taken from the header files, so when you step into a method with parameters that are spelled differently, then you must use the values in the header file to inspect the variables.</p>
<p>Here is an example I mocked up where the parameters were x and y in the header files.</p>
<p><img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="184" alt="CppDebugging" src="http://www.alteridem.net/wp-content/uploads/2007/09/cppdebugging.jpg" width="443" border="0"> </p>
<p>I also tried this in unmanaged C++ and got the same result.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.alteridem.net/2007/09/11/debugging-c-method-parameters/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
