<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>Object Mentor Blog: Exploding Link Stubs in C</title>
    <link>http://blog.objectmentor.com/articles/2008/11/07/exploding-link-stubs-in-c</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description></description>
    <item>
      <title>Exploding Link Stubs in C</title>
      <description>&lt;p&gt;When you&#8217;re working in a batch of legacy C code, it&#8217;s often hard to build and test just a part of it.  You may want to build some set of functions, but then you discover that they call other functions, and those functions call yet other functions.   When link dependencies are very bad, you may discover that you&#8217;re linking in the entire system.&lt;/p&gt;
&lt;p&gt;Fortunately, there is a way out of this.  
Pick a set of files that appear to be a &#8220;component&#8221; and attempt to build them into an executable along with a simple main function.&lt;/p&gt; 
&lt;p&gt;You will get link errors.&lt;/p&gt;
&lt;p&gt;Create a file called &lt;code&gt;&amp;lt;componentname&amp;gt;_stubs.c&lt;/code&gt;  and then go through each of the link errors.  Look up the full declaration of the variable or function the error describes.  Create a stub for each of them in the stub file.&lt;/p&gt;  &lt;p&gt;Here&#8217;s an example of a function stub:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;
int irc_send_ppr(struct ppr *pprn, int nSize)
{
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;
The only problem with this is that you have to place something in the stub function.  For functions which return values you need to, at the very least, provide a return value.  But what should it be?&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;
int irc_send_ppr(struct ppr *pprn, int nSize)
{
  /* is negative -1 okay?   If it isn&#8217;t, how will we know? */
  return -1;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;There is alternative ++:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;
int irc_send_ppr(struct ppr *pprn, int nSize)
{
  assert(!&#8221;irc_send_ppr boom!!&#8221;);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This is an &lt;i&gt;exploding link stub&lt;/i&gt;.  When you have it in place, you &lt;i&gt;will&lt;/i&gt; know when a function you&amp;#8217;re testing calls a stub.  When you see the boom you go to the code and replace the assert with a better stub implementation.&lt;/p&gt;

&lt;p&gt;When you use link stubs, you have to be able to build your component two different ways.  Production builds link to the rest of the code. Test builds link to the stubs and a testing main. There&amp;#8217;s no need to stub out all of the external functions that a component uses.  Many low level functions can remain direct calls, but stubbing out calls to other high level components can give you a decent amount of leverage as you try to get an area under test.&lt;/p&gt; &lt;p&gt;Fortunately, for any given component you only have to go through the massive grunt work once.  Once you do, you can reap the reward of easier testing in that component forever.&lt;/p&gt;
&lt;p&gt;
&lt;i&gt;++ Note: If you are using &lt;span class="caps"&gt;C99&lt;/span&gt;, you can genericize this code by using the &lt;code&gt;__func__&lt;/code&gt; predefined macro.  In any function, &lt;code&gt;__func__ &lt;/code&gt; expands to the name of the enclosing function.&lt;/i&gt;&lt;/p&gt;</description>
      <pubDate>Fri, 07 Nov 2008 19:33:00 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:b4de149a-1d4a-417e-8846-e967259ea38c</guid>
      <author>Michael Feathers</author>
      <link>http://blog.objectmentor.com/articles/2008/11/07/exploding-link-stubs-in-c</link>
      <category>Michaels Musings</category>
    </item>
    <item>
      <title>"Exploding Link Stubs in C" by Writing Blog</title>
      <description>&lt;p&gt;I&#8217;ve been visiting your blog for a while now and I always find a gem in your new posts. Thanks for sharing&lt;/p&gt;</description>
      <pubDate>Thu, 10 May 2012 23:34:23 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:e26b750d-434e-4cd2-bf53-e86e6b82fe6b</guid>
      <link>http://blog.objectmentor.com/articles/2008/11/07/exploding-link-stubs-in-c#comment-223647</link>
    </item>
    <item>
      <title>"Exploding Link Stubs in C" by desktop wallpaper</title>
      <description>&lt;p&gt;I like very much your way of presentation.. I got more useful information on this blog.. Thanks to sharing the useful information&#8230;.&lt;/p&gt;</description>
      <pubDate>Sun, 22 Apr 2012 05:09:28 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:40b71570-0d13-4ec5-ad52-76b7d3cb98d9</guid>
      <link>http://blog.objectmentor.com/articles/2008/11/07/exploding-link-stubs-in-c#comment-219455</link>
    </item>
    <item>
      <title>"Exploding Link Stubs in C" by louboutin sales</title>
      <description>&lt;p&gt;Exploding Link Stubs in C
 47
hoo,good article!!I like the post!93&lt;/p&gt;</description>
      <pubDate>Sat, 21 Apr 2012 01:16:06 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:0cf4743c-ce20-4d39-80e8-373683645a06</guid>
      <link>http://blog.objectmentor.com/articles/2008/11/07/exploding-link-stubs-in-c#comment-219150</link>
    </item>
    <item>
      <title>"Exploding Link Stubs in C" by bladeless fans</title>
      <description>&lt;p&gt;Exploding Link Stubs in C
 46
good post24&lt;/p&gt;</description>
      <pubDate>Fri, 20 Apr 2012 18:42:03 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:1b3a925e-a7f1-4cbf-a8b6-26a5608ec30b</guid>
      <link>http://blog.objectmentor.com/articles/2008/11/07/exploding-link-stubs-in-c#comment-218973</link>
    </item>
    <item>
      <title>"Exploding Link Stubs in C" by best short haircuts 2012</title>
      <description>&lt;p&gt;I like very much your way of presentation.. I got more useful information on this blog.. Thanks to sharing the useful information&#8230;.&lt;/p&gt;</description>
      <pubDate>Tue, 03 Apr 2012 06:53:29 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:5a2c12de-7d12-4ac1-9336-e6d627bb830a</guid>
      <link>http://blog.objectmentor.com/articles/2008/11/07/exploding-link-stubs-in-c#comment-215052</link>
    </item>
    <item>
      <title>"Exploding Link Stubs in C" by short hairstyles for women</title>
      <description>&lt;p&gt;Thanks for taking this opportunity to converse about this, I feel fervently about this and I like learning about this subject. Please, as you gain facts, please update this blog with more information. I have found it extremely useful.&lt;/p&gt;</description>
      <pubDate>Tue, 03 Apr 2012 06:53:01 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:5f97da4b-67e5-45f0-85c1-daf19710cb21</guid>
      <link>http://blog.objectmentor.com/articles/2008/11/07/exploding-link-stubs-in-c#comment-215051</link>
    </item>
    <item>
      <title>"Exploding Link Stubs in C" by celebrity gossip</title>
      <description>&lt;p&gt;I&#8217;ll be visiting your site again to gather some more valuable information.&lt;/p&gt;</description>
      <pubDate>Mon, 19 Mar 2012 01:38:02 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:a50b9ced-c9e9-46c0-b111-f0ea5782f877</guid>
      <link>http://blog.objectmentor.com/articles/2008/11/07/exploding-link-stubs-in-c#comment-211351</link>
    </item>
    <item>
      <title>"Exploding Link Stubs in C" by mbtshoe</title>
      <description>&lt;p&gt;Australia Beats By Dre Studio dr dre beats headphones beats studio beats pro beats solo hd pro headphones music Official store Monster Beats By Dre Pro&lt;/p&gt;</description>
      <pubDate>Tue, 06 Mar 2012 07:02:07 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:3fa4cba2-cd03-43b2-abe5-6262dfc36f40</guid>
      <link>http://blog.objectmentor.com/articles/2008/11/07/exploding-link-stubs-in-c#comment-208360</link>
    </item>
    <item>
      <title>"Exploding Link Stubs in C" by short hairstyles for women</title>
      <description>&lt;p&gt;&amp;#8220;It is perfect time to make some plans for the future and it&amp;#8217;s time to be happy. I have read this post and I really really like the topic about gadgets.
&amp;#8220;&lt;/p&gt;</description>
      <pubDate>Wed, 29 Feb 2012 08:34:22 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:6d953430-7b41-4ff3-b4a1-94db3fe3aa4e</guid>
      <link>http://blog.objectmentor.com/articles/2008/11/07/exploding-link-stubs-in-c#comment-206818</link>
    </item>
    <item>
      <title>"Exploding Link Stubs in C" by Easy to do hairstyles</title>
      <description>&lt;p&gt;This article is GREAT it can be EXCELLENT JOB and what a great tool!&lt;/p&gt;</description>
      <pubDate>Sat, 25 Feb 2012 01:26:03 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:8b8f00ad-096b-48de-8b1d-503e80fa2888</guid>
      <link>http://blog.objectmentor.com/articles/2008/11/07/exploding-link-stubs-in-c#comment-206002</link>
    </item>
    <item>
      <title>"Exploding Link Stubs in C" by ralph lauren</title>
      <description>&lt;p&gt;Si&#232;cle S&#233;rie classique am&#233;ricain de los angeles marque Ralph Lauren hommes d&amp;#8217;hiver communiqu&#233; de 2012, los angeles principale saison des longues de design guy cuir, cr&#233;ateurs intelligents ajout&#233; fermeture &#233;clair dans los angeles couche moyenne de cuir, veste durante cuir cuando longtemps devient instantan&#233;ment courtroom. Los angeles couleur beige et noir &#233;galement, put cr&#233;er united nations design parfait guy scandinaves.&lt;a href="http://www.vetementpoloralphlauren2012.net" rel="nofollow"&gt;http://www.vetementpoloralphlauren2012.net&lt;/a&gt;&lt;/p&gt;</description>
      <pubDate>Thu, 02 Feb 2012 02:47:36 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:40a23065-d301-4863-b5a7-a17adec9ad55</guid>
      <link>http://blog.objectmentor.com/articles/2008/11/07/exploding-link-stubs-in-c#comment-200737</link>
    </item>
    <item>
      <title>"Exploding Link Stubs in C" by Microsoft Office</title>
      <description>&lt;p&gt;This article is GREAT it can be EXCELLENT JOB and what a great tool!&lt;/p&gt;</description>
      <pubDate>Fri, 13 Jan 2012 20:37:18 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:6c15eea8-b0a7-4f85-9099-94b028d9a161</guid>
      <link>http://blog.objectmentor.com/articles/2008/11/07/exploding-link-stubs-in-c#comment-197759</link>
    </item>
    <item>
      <title>"Exploding Link Stubs in C" by sallyerma</title>
      <description>&lt;p&gt;I have been searching all over the blogs for a relevant article related to this topic for a paper I am writing. I&#8217;ll be sure to come back to your blog for other valuable information next time I need solid information on this subject.
&lt;a href="http://www.stylesnew.com/hairstyles/styles/layered/" rel="nofollow"&gt;layered hairstyles&lt;/a&gt;&lt;/p&gt;</description>
      <pubDate>Mon, 09 Jan 2012 17:48:07 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:65b62f4c-ea9b-4495-a1b0-140f1e529cf1</guid>
      <link>http://blog.objectmentor.com/articles/2008/11/07/exploding-link-stubs-in-c#comment-196416</link>
    </item>
    <item>
      <title>"Exploding Link Stubs in C" by iphone contacts backup</title>
      <description>&lt;p&gt;explore a way to backup iPhone contacts&lt;/p&gt;</description>
      <pubDate>Sat, 07 Jan 2012 06:42:42 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:940a4bf4-c0a7-4530-a0f8-bf957d8ba9ba</guid>
      <link>http://blog.objectmentor.com/articles/2008/11/07/exploding-link-stubs-in-c#comment-195906</link>
    </item>
    <item>
      <title>"Exploding Link Stubs in C" by grad school personal statement</title>
      <description>&lt;p&gt;Thank you for the efforts you been putting on making your site such an interesting and informative place to browse through. I&amp;#8217;ll be visiting your site again to gather some more valuable information.&lt;/p&gt;</description>
      <pubDate>Fri, 23 Dec 2011 09:58:04 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:7aab16d3-4f54-4e7c-9509-cb69a05a2727</guid>
      <link>http://blog.objectmentor.com/articles/2008/11/07/exploding-link-stubs-in-c#comment-190866</link>
    </item>
    <item>
      <title>"Exploding Link Stubs in C" by write writer</title>
      <description>&lt;p&gt;I learned something new just by trying your codes and tweaking them just a little bit, it was really all a good help, thanks for those info and kudos!&lt;/p&gt;</description>
      <pubDate>Wed, 14 Dec 2011 01:52:01 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:87d19b3b-8a5a-49f5-8937-5494916a1688</guid>
      <link>http://blog.objectmentor.com/articles/2008/11/07/exploding-link-stubs-in-c#comment-186347</link>
    </item>
    <item>
      <title>"Exploding Link Stubs in C" by alwadifa</title>
      <description>&lt;p&gt;I liked you blog so im going bookmark it with my prefered websites, you have posted an amazing posts so thank you I liked you blog so im going bookmark it with my prefered websites, you have posted an amazing posts so thank you&lt;/p&gt;</description>
      <pubDate>Sat, 05 Nov 2011 17:53:34 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:5bca8893-eb97-49e6-b334-68dbddabf679</guid>
      <link>http://blog.objectmentor.com/articles/2008/11/07/exploding-link-stubs-in-c#comment-168766</link>
    </item>
    <item>
      <title>"Exploding Link Stubs in C" by Tips For Bowling</title>
      <description>&lt;p&gt;People were so keen to get investment. In those days, there was quite significant unemployment in Northern Ireland, and that had been the general pattern in Northern Ireland for many, many years.
John Hume&lt;/p&gt;</description>
      <pubDate>Thu, 20 Oct 2011 13:34:57 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:9a8ea144-41f7-4ecf-99ba-9f36537036a5</guid>
      <link>http://blog.objectmentor.com/articles/2008/11/07/exploding-link-stubs-in-c#comment-160244</link>
    </item>
    <item>
      <title>"Exploding Link Stubs in C" by Discount Gucci Sale</title>
      <description>&lt;p&gt;Just want to say what a great blog you got here!I&amp;#8217;ve been around for quite a lot of time, but finally decided to show my appreciation of your work!&lt;/p&gt;</description>
      <pubDate>Thu, 06 Oct 2011 23:27:19 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:0c90c7ce-c97f-481a-8a14-f7115e2b6e9a</guid>
      <link>http://blog.objectmentor.com/articles/2008/11/07/exploding-link-stubs-in-c#comment-151486</link>
    </item>
    <item>
      <title>"Exploding Link Stubs in C" by anji843</title>
      <description>&lt;p&gt;This is very much enjoyed for the great services in this website. I am very much happy for providing the great technology is visible in this website that to using the great services in this blog &lt;a href="http://webmasterjobdescription.net/ " rel="nofollow"&gt; Webmaster Job Description&lt;/a&gt;&lt;/p&gt;</description>
      <pubDate>Mon, 03 Oct 2011 01:52:18 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:140476b3-93fe-43a1-bdf4-342ac424c7a8</guid>
      <link>http://blog.objectmentor.com/articles/2008/11/07/exploding-link-stubs-in-c#comment-149415</link>
    </item>
    <item>
      <title>"Exploding Link Stubs in C" by &lt;a href="http://executivedirectorjobdescription.org/ "&gt;Executive Director Job Description&lt;/a&gt;</title>
      <description>&lt;p&gt;This is very much impressed with the great services in this blog that to using the great technology in this blog. I am really interesting info is visible in this blog that to sharing the great services in this blog that to using the great services in this blog. This is very much impressed with the great technology is visible in this blog that to sharing the great services in this blog &lt;a href="http://executivedirectorjobdescription.org/ " rel="nofollow"&gt;Executive Director Job Description&lt;/a&gt;|&lt;a href="http://generalmanagerjobdescription.org/ " rel="nofollow"&gt; General Manager Job Description&lt;/a&gt;|&lt;a href="http://consultantjobdescription.net/ " rel="nofollow"&gt; Consultant Job Description&lt;/a&gt; Webmaster Job Description&lt;/p&gt;</description>
      <pubDate>Mon, 03 Oct 2011 01:49:46 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:3ac56ebb-2dd8-427e-bc6e-435b69a20335</guid>
      <link>http://blog.objectmentor.com/articles/2008/11/07/exploding-link-stubs-in-c#comment-149414</link>
    </item>
    <item>
      <title>"Exploding Link Stubs in C" by Tory Burch outlet store</title>
      <description>&lt;p&gt;It&#8217;s great when you find relevant content .I can&#8217;t stay without admiring your post its really awesome thanks for sharing such a nice content.&lt;/p&gt;</description>
      <pubDate>Tue, 27 Sep 2011 20:31:15 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:cfb8e680-99e1-4347-890a-1b24a69a1b27</guid>
      <link>http://blog.objectmentor.com/articles/2008/11/07/exploding-link-stubs-in-c#comment-146282</link>
    </item>
    <item>
      <title>"Exploding Link Stubs in C" by DR OZ african Mango </title>
      <description>&lt;p&gt;When I at first left a comment I clicked the &amp;#8220;Notify me when new comments are added&amp;#8221; checkbox and now each time a comment is added I get three notification emails with the same comment. Is there any way you can take away people from that service? Thanks a lot!&lt;/p&gt;</description>
      <pubDate>Tue, 27 Sep 2011 11:15:50 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:17eabad7-20cb-4aae-b275-d81f69634b11</guid>
      <link>http://blog.objectmentor.com/articles/2008/11/07/exploding-link-stubs-in-c#comment-146107</link>
    </item>
    <item>
      <title>"Exploding Link Stubs in C" by christianlouboutin</title>
      <description>&lt;p&gt;All among us realise that if you MBT boots or shoes within get hold of, &lt;a href="http://www.louboutinchaussures-fr.com/jimmy-choo-jimmy-choo-sandales-39_36/" rel="nofollow"&gt;Jimmy Choo Sandales&lt;/a&gt;education-women&#8217; vertisements mbt tunisha providing may easily really encourages lymphatic circulation,&lt;a href="http://www.louboutinchaussures-fr.com/jimmy-choo-jimmy-choo-bottines-39_33/" rel="nofollow"&gt;Jimmy Choo Bottines&lt;/a&gt; you&#8217; chemical in all probability more significant receive boots or shoes clearance retail store as a result of MBT while it a good number of at no cost submitting in combination with MBT boots or shoes are almost always pay for and also profit designed notnax&lt;a href="http://www.canadagoosejakkedk.com" rel="nofollow"&gt;&lt;strong&gt;canada goose outlet&lt;/strong&gt;&lt;/a&gt;.&lt;/p&gt;


	&lt;pre&gt;&lt;code&gt;A particular low-priced MBT Nama Boots and shoes out of a number of online space boots and shoes plus boot footwear MBT great bargains preferred now in now would be to simply and even safely mbt sandals pay for consumers pay for progressively more over the internet&lt;a href="http://www.canadagoosejakkedk.com" rel="nofollow"&gt;&lt;strong&gt;canada goose jakke&lt;/strong&gt;&lt;/a&gt;, have MBT footwear and remaining grown to be a sample. MBT boots providing now, ways to explain any one prevent&lt;p&gt;&lt;a href="http://www.north-face-jakke.com/" rel="nofollow"&gt;&lt;em&gt;&lt;strong&gt;the north face&lt;/strong&gt;&lt;/em&gt;&lt;/a&gt;&lt;/p&gt;? Brand-new assumed to test a person's MBT boots pay for, generate a test? My wife and i reassurance any one, we have a special working experience&lt;p&gt;&lt;a href="http://www.north-face-jakke.com/" rel="nofollow"&gt;&lt;em&gt;&lt;strong&gt;North Face Denali Jakker Kvinder hoodie&lt;/strong&gt;&lt;/em&gt;&lt;/a&gt;&lt;/p&gt;.&lt;/code&gt;&lt;/pre&gt;</description>
      <pubDate>Fri, 16 Sep 2011 22:31:31 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:0777f794-14e1-4e38-b5bf-b62172f1cf3d</guid>
      <link>http://blog.objectmentor.com/articles/2008/11/07/exploding-link-stubs-in-c#comment-141518</link>
    </item>
    <item>
      <title>"Exploding Link Stubs in C" by http://www.essay-service.org/research-paper</title>
      <description>&lt;p&gt;When I see a lot of methods and C codes It&amp;#8217;s hard for me to understand some codes. That&#8217;s an example of me interpreting without reading. You have to analyse that thoroughly and quickly.&lt;/p&gt;</description>
      <pubDate>Wed, 07 Sep 2011 05:03:23 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:67058ee6-f0b1-406e-bad6-2d19145c2e77</guid>
      <link>http://blog.objectmentor.com/articles/2008/11/07/exploding-link-stubs-in-c#comment-138065</link>
    </item>
  </channel>
</rss>

