<?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>Visual C++ Tips &#187; Visual C++ Preprocessors</title>
	<atom:link href="http://weseetips.com/category/visual-c-preprocessors/feed/" rel="self" type="application/rss+xml" />
	<link>http://weseetips.com</link>
	<description>Gold mine of Visual C++ tricks!</description>
	<lastBuildDate>Thu, 11 Mar 2010 09:09:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>How to enable warning for Deprecated Functions?</title>
		<link>http://weseetips.com/2008/12/22/how-to-enable-warning-for-deprecated-functions/</link>
		<comments>http://weseetips.com/2008/12/22/how-to-enable-warning-for-deprecated-functions/#comments</comments>
		<pubDate>Mon, 22 Dec 2008 20:06:45 +0000</pubDate>
		<dc:creator>Jijo Raj</dc:creator>
				<category><![CDATA[Codeproject]]></category>
		<category><![CDATA[Visual C++ Preprocessors]]></category>
		<category><![CDATA[#pragma deprecated]]></category>
		<category><![CDATA[deprecated]]></category>
		<category><![CDATA[deprecated classes]]></category>
		<category><![CDATA[deprecated function]]></category>
		<category><![CDATA[deprecated function warning]]></category>
		<category><![CDATA[deprecated functions]]></category>
		<category><![CDATA[deprecated member functions]]></category>
		<category><![CDATA[deprecated overloaded functions]]></category>
		<category><![CDATA[deprecated symbols]]></category>
		<category><![CDATA[visual studio 2005]]></category>
		<category><![CDATA[Visual Studio 2008]]></category>
		<category><![CDATA[warning deprecated function]]></category>
		<category><![CDATA[__declspec deprecated]]></category>
		<category><![CDATA[__declspec(deprecated)]]></category>

		<guid isPermaLink="false">http://weseetips.com/?p=754</guid>
		<description><![CDATA[If you port some of your old vc6 projects to Visual Studio 2005, you might have noticed that several function have become deprecated. Well, if you are a framework writer, its handy to notify user about the function which existed but deprecated. Well, how to do it? You can use #pragma deprecated or __declspec(deprecated) to [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-medium wp-image-11" title="Icon Description" src="http://weseetips.wordpress.com/files/2008/03/icon_description.jpg?w=166" alt="" width="166" height="32" /><br />
If you port some of your old vc6 projects to Visual Studio 2005, you might have noticed that several function have become deprecated. Well, <span style="color:#0000ff;">if you are a framework writer, its handy to notify user about the function which existed but deprecated.</span> Well, how to do it?<br />
<img class="alignnone size-full wp-image-757" title="depricatedfunction2" src="http://weseetips.wordpress.com/files/2008/12/depricatedfunction2.jpg" alt="depricatedfunction2" width="375" height="264" /></p>
<p><img class="alignnone size-medium wp-image-12" title="Icon How Can I Do It?" src="http://weseetips.wordpress.com/files/2008/03/icon_howcanidoit.jpg?w=220" alt="" width="220" height="32" /><br />
You can use <span style="color:#0000ff;">#pragma deprecated</span> or <span style="color:#0000ff;">__declspec(deprecated)</span> to mark the deprecated functions. Then, if the function is used, compiler will shoot a warning while compiling. Check the code snippet below for how to do it in different conditions.</p>
<p><span style="text-decoration:underline;"><strong>1) Deprecated Functions</strong></span></p>
<pre>// If you want to set Fun1() and Fun2() as deprecated.
#pragma deprecated(Fn1, Fn2)
Fn1();   // C4995
Fn2();   // C4995</pre>
<p>or</p>
<pre>// If you use __declspec(deprecated), then you can
// provide an error message as well.
void __declspec(deprecated("Fn1 is not supported")) Fn1()
{}</pre>
<p><span style="text-decoration:underline;"><strong>2) Depricated Class</strong></span></p>
<pre>// If you want to set a class as deprecated.
#pragma deprecated( CFooBar )
CFooBar obj;   // C4995</pre>
<p>or</p>
<pre>// If you want to mark deprecated by using __declspec(deprecated)
class __declspec( deprecated("No Longer supported")) CFooBar
{};</pre>
<p><span style="text-decoration:underline;"><strong>3) Overloaded Member functions</strong></span></p>
<pre>class CFooBar
{
public:
    void Fun1()
    {}

    // Deprecating one of overloaded function.
    void __declspec(deprecated) Fun1( int a )
    {}
};
...
CFooBar obj;
obj.Fun1();        // Okay.
obj.Fun1( 0 );    // Error.</pre>
<p><span style="text-decoration:underline;"><strong>4) Error on deprecated function usage</strong></span><br />
If you enable &#8211; <span style="color:#0000ff;">&#8220;Warning as errors&#8221;</span> in Project settings, then the <span style="color:#0000ff;">usage deprecated functions will halt the compilation</span> which will be even more noticeable. Check the screenshot.<br />
<img class="alignnone size-full wp-image-758" title="deprecatedfunctions1" src="http://weseetips.wordpress.com/files/2008/12/deprecatedfunctions1.jpg" alt="deprecatedfunctions1" width="510" height="355" /></p>
<p><img class="alignnone size-medium wp-image-18" title="Icon Note" src="http://weseetips.wordpress.com/files/2008/03/icon_note.jpg?w=94" alt="" width="94" height="32" /><br />
Well, take care that this functionality is <span style="color:#0000ff;">only available for visual studio 2005 and younger siblings.<br />
</span></p>
<p><img class="alignnone size-medium wp-image-51" title="beginnerseries" src="http://weseetips.wordpress.com/files/2008/03/beginnerseries.jpg?w=215" alt="" width="215" height="32" /><br />
Targeted Audience &#8211; Beginners.</p>
]]></content:encoded>
			<wfw:commentRss>http://weseetips.com/2008/12/22/how-to-enable-warning-for-deprecated-functions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

