<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" version="2.0"><channel><title>Varied Thoughts</title> <link>http://variedthoughts.com</link> <description>A Programmers Notebook</description> <lastBuildDate>Wed, 10 Apr 2013 16:41:02 +0000</lastBuildDate> <language>en-US</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.5</generator> <atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/variedthoughts/dAIN" /><feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="variedthoughts/dain" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:emailServiceId xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0">variedthoughts/dAIN</feedburner:emailServiceId><feedburner:feedburnerHostname xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0">http://feedburner.google.com</feedburner:feedburnerHostname><item><title>The lamest GitHub project</title><link>http://variedthoughts.com/programming/lamest-github-project/</link> <comments>http://variedthoughts.com/programming/lamest-github-project/#comments</comments> <pubDate>Thu, 15 Nov 2012 05:21:25 +0000</pubDate> <dc:creator>Brian</dc:creator> <category><![CDATA[Programming]]></category> <category><![CDATA[github]]></category> <category><![CDATA[markdown]]></category> <category><![CDATA[python]]></category><guid isPermaLink="false">http://variedthoughts.com/?p=538</guid> <description><![CDATA[<p>I&#8217;ve just pushed the first version of markdown.py to GitHub. It doesn&#8217;t do anything except echo the contents of any file you give it. The reason why it&#8217;s useful at all are documented in Stub for markdown.py. However, it occurred to me that as it stands now, it might be the lamest, most useless project [...]</p><p>The post <a
href="http://variedthoughts.com/programming/lamest-github-project/">The lamest GitHub project</a> appeared first on <a
href="http://variedthoughts.com">Varied Thoughts</a>.</p>]]></description> <content:encoded><![CDATA[<p>I&#8217;ve just pushed the first version of <a
href="https://github.com/variedthoughts/markdown.py">markdown.py to GitHub</a>.<br
/> It doesn&#8217;t do anything except echo the contents of any file you give it.</p><p>The reason why it&#8217;s useful at all are documented in <a
href="http://pythontesting.net/markdown/stub-markdown/">Stub for markdown.py</a>.</p><p>However, it occurred to me that as it stands now, it might be the lamest, most useless project on GitHub right now.</p><p>Hopefully it won&#8217;t remain useless and lame, if course.</p><p>The post <a
href="http://variedthoughts.com/programming/lamest-github-project/">The lamest GitHub project</a> appeared first on <a
href="http://variedthoughts.com">Varied Thoughts</a>.</p>]]></content:encoded> <wfw:commentRss>http://variedthoughts.com/programming/lamest-github-project/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Clearcase checkout from vim on windows with cygwin</title><link>http://variedthoughts.com/programming/clearcase-checkout-vim-windows-cygwin/</link> <comments>http://variedthoughts.com/programming/clearcase-checkout-vim-windows-cygwin/#comments</comments> <pubDate>Mon, 05 Nov 2012 15:28:37 +0000</pubDate> <dc:creator>Brian</dc:creator> <category><![CDATA[Programming]]></category> <category><![CDATA[bash]]></category> <category><![CDATA[clearcase]]></category> <category><![CDATA[cygwin]]></category> <category><![CDATA[vim]]></category><guid isPermaLink="false">http://variedthoughts.com/?p=531</guid> <description><![CDATA[<p>One of the projects I&#8217;m working on uses ClearCase. I am developing on Windows 7, with cygwin. I edit in Vim. To get integration between Vim and ClearCase, I&#8217;m using the ccase.vim plugin. However, I need to make a couple of changes to the default to get it to work. In my _vimrc file, add [...]</p><p>The post <a
href="http://variedthoughts.com/programming/clearcase-checkout-vim-windows-cygwin/">Clearcase checkout from vim on windows with cygwin</a> appeared first on <a
href="http://variedthoughts.com">Varied Thoughts</a>.</p>]]></description> <content:encoded><![CDATA[<p>One of the projects I&#8217;m working on uses <a
href="http://en.wikipedia.org/wiki/IBM_Rational_ClearCase">ClearCase</a>.<br
/> I am developing on Windows 7, with <a
href="http://www.cygwin.com">cygwin</a>.<br
/> I edit in <a
href="http://www.vim.org">Vim</a>.</p><p>To get integration between Vim and ClearCase, I&#8217;m using the <a
href="http://www.vim.org/scripts/script.php?script_id=15">ccase.vim</a> plugin.</p><p>However, I need to make a couple of changes to the default to get it to work.</p><ol><li>In my _vimrc file, add this: <code>set shell=C:/cygwin/bin/bash</code></li><li>In ccase.vim, replace all of the lines that look like this:<br
/> <code>let l:file = resolve (expand("%:p"))</code><br
/> to:<br
/> <code>let l:file = resolve (expand("%:p:gs?\\?/?"))</code></ol><p>I didn&#8217;t have to do that on the XP machine I was using before.<br
/> I don&#8217;t know what&#8217;s different.<br
/> But the above steps fix it.</p><p>The post <a
href="http://variedthoughts.com/programming/clearcase-checkout-vim-windows-cygwin/">Clearcase checkout from vim on windows with cygwin</a> appeared first on <a
href="http://variedthoughts.com">Varied Thoughts</a>.</p>]]></content:encoded> <wfw:commentRss>http://variedthoughts.com/programming/clearcase-checkout-vim-windows-cygwin/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Stop Sucking</title><link>http://variedthoughts.com/programming/stop-sucking/</link> <comments>http://variedthoughts.com/programming/stop-sucking/#comments</comments> <pubDate>Mon, 29 Oct 2012 23:51:45 +0000</pubDate> <dc:creator>Brian</dc:creator> <category><![CDATA[Programming]]></category><guid isPermaLink="false">http://variedthoughts.com/?p=526</guid> <description><![CDATA[<p>Not sure how I missed this before. But it&#8217;s pretty awesome. how to stop sucking and be awesome instead</p><p>The post <a
href="http://variedthoughts.com/programming/stop-sucking/">Stop Sucking</a> appeared first on <a
href="http://variedthoughts.com">Varied Thoughts</a>.</p>]]></description> <content:encoded><![CDATA[<p>Not sure how I missed this before.<br
/> But it&#8217;s pretty awesome.<br
/> <a
href='http://www.slideshare.net/slideshow/embed_code/13158025'>how to stop sucking and be awesome instead</a></p><p>The post <a
href="http://variedthoughts.com/programming/stop-sucking/">Stop Sucking</a> appeared first on <a
href="http://variedthoughts.com">Varied Thoughts</a>.</p>]]></content:encoded> <wfw:commentRss>http://variedthoughts.com/programming/stop-sucking/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Functional Testing, Python, and Markdown. Oh My!</title><link>http://variedthoughts.com/programming/python-testing/</link> <comments>http://variedthoughts.com/programming/python-testing/#comments</comments> <pubDate>Thu, 25 Oct 2012 04:52:05 +0000</pubDate> <dc:creator>Brian</dc:creator> <category><![CDATA[Programming]]></category><guid isPermaLink="false">http://variedthoughts.com/?p=521</guid> <description><![CDATA[<p>It sure has been quest around here. Actually, I&#8217;ve been busy thinking about and writing about: + python programming + python testing + functional testing + and Markdown But it&#8217;s all happening over at PythonTesting.net. So head on over there, and check it out.</p><p>The post <a
href="http://variedthoughts.com/programming/python-testing/">Functional Testing, Python, and Markdown. Oh My!</a> appeared first on <a
href="http://variedthoughts.com">Varied Thoughts</a>.</p>]]></description> <content:encoded><![CDATA[<p>It sure has been quest around here.<br
/> Actually, I&#8217;ve been busy thinking about and writing about:<br
/> + python programming<br
/> + python testing<br
/> + functional testing<br
/> + and Markdown</p><p>But it&#8217;s all happening over at <a
href="http://pythontesting.net/">PythonTesting.net</a>.</p><p>So head on over there, and check it out.</p><p>The post <a
href="http://variedthoughts.com/programming/python-testing/">Functional Testing, Python, and Markdown. Oh My!</a> appeared first on <a
href="http://variedthoughts.com">Varied Thoughts</a>.</p>]]></content:encoded> <wfw:commentRss>http://variedthoughts.com/programming/python-testing/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>true &amp;&amp; false</title><link>http://variedthoughts.com/programming/true-false/</link> <comments>http://variedthoughts.com/programming/true-false/#comments</comments> <pubDate>Tue, 26 Jun 2012 11:35:07 +0000</pubDate> <dc:creator>Brian</dc:creator> <category><![CDATA[Programming]]></category> <category><![CDATA[false]]></category> <category><![CDATA[true]]></category><guid isPermaLink="false">http://variedthoughts.com/?p=482</guid> <description><![CDATA[<p>or is it True and False, &#8230;? Boolean logic is just part of the job as a programmer. However, language writers have  made our life complicated. We don&#8217;t just have 0 and 1 for true and false. We have types such as bool, Bool, boolean, Boolean. We have true, True, TRUE, false, False, FALSE, 0, [...]</p><p>The post <a
href="http://variedthoughts.com/programming/true-false/">true &#038;&#038; false</a> appeared first on <a
href="http://variedthoughts.com">Varied Thoughts</a>.</p>]]></description> <content:encoded><![CDATA[<p><em>or is it True and False, &#8230;?</em></p><p>Boolean logic is just part of the job as a programmer.</p><p>However, language writers have  made our life complicated.</p><p>We don&#8217;t just have 0 and 1 for true and false.</p><p>We have types such as bool, Bool, boolean, Boolean.</p><p>We have true, True, TRUE, false, False, FALSE, 0, 1, non-zero, non-empty, NULL, &#8230; AARRG!!!!</p><p>It&#8217;s really not a big deal if you just program in one language. But who does that anymore?</p><p>I&#8217;m often programming in C++, C, perl, python, bash, javaScript, and PHP all in one day.</p><p>So what&#8217;s a person to do.</p><p>Personally, I set up vim colorization based on file extension such that the correct types get colored. And if I mess it up, it doesn&#8217;t get colored.</p><p>However, it&#8217;s still frustrating.</p><p>Anyone out there got a simple cheat sheet or mnemonic to keep it all straight?</p><p>The post <a
href="http://variedthoughts.com/programming/true-false/">true &#038;&#038; false</a> appeared first on <a
href="http://variedthoughts.com">Varied Thoughts</a>.</p>]]></content:encoded> <wfw:commentRss>http://variedthoughts.com/programming/true-false/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>py.test from behind a firewall</title><link>http://variedthoughts.com/programming/pytest-firewall/</link> <comments>http://variedthoughts.com/programming/pytest-firewall/#comments</comments> <pubDate>Mon, 09 Apr 2012 22:40:16 +0000</pubDate> <dc:creator>Brian</dc:creator> <category><![CDATA[Programming]]></category> <category><![CDATA[pytest]]></category> <category><![CDATA[python]]></category><guid isPermaLink="false">http://variedthoughts.com/?p=330</guid> <description><![CDATA[<p>I wanted to try out pytest (or py.test, I&#8217;ve heard it both ways). But I&#8217;m behind a firewall, so pip and easy_install don&#8217;t work that great. I&#8217;m also running cygwin, with several versions of python so I can test compatibility of scripts across 2.6, 2.7, and 3.2. Trial and error gets me to these steps [...]</p><p>The post <a
href="http://variedthoughts.com/programming/pytest-firewall/">py.test from behind a firewall</a> appeared first on <a
href="http://variedthoughts.com">Varied Thoughts</a>.</p>]]></description> <content:encoded><![CDATA[<p>I wanted to try out <a
href="http://pytest.org">pytest</a> (or py.test, I&#8217;ve heard it both ways).<br
/> But I&#8217;m behind a firewall, so pip and easy_install don&#8217;t work that great.<br
/> I&#8217;m also running cygwin, with several versions of python so I can test compatibility of scripts across 2.6, 2.7, and 3.2.</p><p>Trial and error gets me to these steps that seem to work.</p><ol><li><a
href="http://pypi.python.org/pypi/py">download py</a></li><li>unpack it to directory py147 (whatever you want to name it)</li><li><a
href="http://pypi.python.org/pypi/pytest">download pytest</a></li><li> unpack it to directory pytest223 (again, whatever you want to name it)</li><li>install py (see below)</li><li>install pytest (see below)</li></ol><p>In this example, I&#8217;ve got a symbolic link in my path called python27 that links to my python 2.7 executable.</p><p>[bash]<br
/> &gt; cd py147<br
/> &gt; python27 setup.py install<br
/> &gt; cd ../pytest223<br
/> &gt; python27 setup.py install</p><p># now test it by running one of the pytest included scripts<br
/> &gt; cd testing<br
/> &gt; python27 -m pytest test_python.py<br
/> [/bash]</p><p>Splendid.<br
/> Now getting on to the task of examining it to see if it&#8217;s functionality meets my needs.</p><p><em>Update 4-June-2012:</em></p><p>I just tried this in a new machine and ran into an issue that distribute wasn&#8217;t installed.</p><p>This is fixed simply by downloading and installing  it and trying the rest again.</p><ol><li><a
href="http://pypi.python.org/packages/source/d/distribute/">download distribute</a></li><li>unpack it to directory dist (whatever you want to name it)</li><li><code>cd dist</code></li><li><code>python27 setup.py install</code></li><li>go back up to installing py and py.test (see above)</li></ol><p>The post <a
href="http://variedthoughts.com/programming/pytest-firewall/">py.test from behind a firewall</a> appeared first on <a
href="http://variedthoughts.com">Varied Thoughts</a>.</p>]]></content:encoded> <wfw:commentRss>http://variedthoughts.com/programming/pytest-firewall/feed/</wfw:commentRss> <slash:comments>2</slash:comments> </item> <item><title>Testing in Python</title><link>http://variedthoughts.com/programming/testing-python/</link> <comments>http://variedthoughts.com/programming/testing-python/#comments</comments> <pubDate>Mon, 09 Apr 2012 16:59:53 +0000</pubDate> <dc:creator>Brian</dc:creator> <category><![CDATA[Programming]]></category> <category><![CDATA[pytest]]></category> <category><![CDATA[python]]></category><guid isPermaLink="false">http://variedthoughts.com/?p=326</guid> <description><![CDATA[<p>I&#8217;ve been using Python for writing test code for many years now. I&#8217;ve used several test frameworks, most of them proprietary. However, I&#8217;d like to utilize some of the open source frameworks available. Right now, I&#8217;m doing two things. 1. Writing my own framework. 2. Investigating pytest. Hopefully I will have some results from both [...]</p><p>The post <a
href="http://variedthoughts.com/programming/testing-python/">Testing in Python</a> appeared first on <a
href="http://variedthoughts.com">Varied Thoughts</a>.</p>]]></description> <content:encoded><![CDATA[<p>I&#8217;ve been using Python for writing test code for many years now.<br
/> I&#8217;ve used several test frameworks, most of them proprietary.<br
/> However, I&#8217;d like to utilize some of the open source frameworks available.</p><p>Right now, I&#8217;m doing two things.<br
/> 1. Writing my own framework.<br
/> 2. Investigating <a
href="http://pytest.org">pytest</a>.</p><p>Hopefully I will have some results from both experiences to share.</p><p>The post <a
href="http://variedthoughts.com/programming/testing-python/">Testing in Python</a> appeared first on <a
href="http://variedthoughts.com">Varied Thoughts</a>.</p>]]></content:encoded> <wfw:commentRss>http://variedthoughts.com/programming/testing-python/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>C++ zero padded string from int</title><link>http://variedthoughts.com/programming/padded-string-int/</link> <comments>http://variedthoughts.com/programming/padded-string-int/#comments</comments> <pubDate>Tue, 27 Mar 2012 22:35:53 +0000</pubDate> <dc:creator>Brian</dc:creator> <category><![CDATA[Programming]]></category> <category><![CDATA[c++]]></category> <category><![CDATA[stdlib]]></category> <category><![CDATA[string]]></category><guid isPermaLink="false">http://variedthoughts.com/?p=300</guid> <description><![CDATA[<p>Using an output string stream is a handy way to convert a number to a string. However, what if you want to zero pad the number. Well, that&#8217;s where iomanip comes in handy. [code language="cpp"] #include &#60;iomanip&#62; // for setw, setfill #include &#60;iostream&#62; // for cout #include &#60;sstream&#62; // for ostringstream #include &#60;string&#62; // for [...]</p><p>The post <a
href="http://variedthoughts.com/programming/padded-string-int/">C++ zero padded string from int</a> appeared first on <a
href="http://variedthoughts.com">Varied Thoughts</a>.</p>]]></description> <content:encoded><![CDATA[<p>Using an output string stream is a handy way to convert a number to a string.</p><p>However, what if you want to zero pad the number.</p><p>Well, that&#8217;s where iomanip comes in handy.</p><p>[code language="cpp"]<br
/> #include &lt;iomanip&gt;  // for setw, setfill<br
/> #include &lt;iostream&gt; // for cout<br
/> #include &lt;sstream&gt;  // for ostringstream<br
/> #include &lt;string&gt;   // for string</p><p>using namespace std;</p><p>int main ()<br
/> {<br
/> int i = 1;</p><p> ostringstream ss;<br
/> ss &lt;&lt; setw( 3 ) &lt;&lt; setfill( '0' ) &lt;&lt; i;<br
/> string s = ss.str();</p><p> cout &lt;&lt; &quot;i: &quot; &lt;&lt; i &lt;&lt; endl;<br
/> cout &lt;&lt; &quot;s: &quot; &lt;&lt; s &lt;&lt; endl;<br
/> return 0;<br
/> }</p><p>[/code]</p><p>output:<br
/> [bash]<br
/> i: 1<br
/> s: 001<br
/> [/bash]</p><p>The post <a
href="http://variedthoughts.com/programming/padded-string-int/">C++ zero padded string from int</a> appeared first on <a
href="http://variedthoughts.com">Varied Thoughts</a>.</p>]]></content:encoded> <wfw:commentRss>http://variedthoughts.com/programming/padded-string-int/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>C++ variable scope and the for loop</title><link>http://variedthoughts.com/programming/c-variable-scope-for-loop/</link> <comments>http://variedthoughts.com/programming/c-variable-scope-for-loop/#comments</comments> <pubDate>Thu, 22 Mar 2012 20:28:29 +0000</pubDate> <dc:creator>Brian</dc:creator> <category><![CDATA[Programming]]></category> <category><![CDATA[c++]]></category><guid isPermaLink="false">http://variedthoughts.com/?p=289</guid> <description><![CDATA[<p>C++ allows you to re-use variables in nested scopes. A confusion arises sometimes, especially with those new to C++ rules, as to the variables at the top of a for loop. In a for loop, such as for (int i = 0; i < 2; i++) { ... }, does the int i belong to [...]</p><p>The post <a
href="http://variedthoughts.com/programming/c-variable-scope-for-loop/">C++ variable scope and the for loop</a> appeared first on <a
href="http://variedthoughts.com">Varied Thoughts</a>.</p>]]></description> <content:encoded><![CDATA[<p>C++ allows you to re-use variables in nested scopes.</p><p>A confusion arises sometimes, especially with those new to C++ rules, as to the variables at the top of a for loop.</p><p>In a for loop, such as <strong>for (<em>int i</em> = 0; i < 2; i++) { ... }</strong>, does the <em>int i</em> belong to the outer scope or the scope within the for loop.</p><p>The answer is that it belongs to the inner loop, and hides any outer variables, if they exist.<br
/> Of course, this is best shown with an example.</p><p>Three variables: i, j, k<br
/> Variable i is defined both in the outer scope and as a loop index variable defined in the top of the for statement.<br
/> Variable j is defined both in the outer scope and within the curly brackets of the for loop.<br
/> Variable k is only defined in the outer scope.</p><p>The treatment of i is the same as j. It&#8217;s as if all of the statements at the top of the for loop are <em>inside</em> the curly brackets of the for loop.</p><p>Sample Code:<br
/> [code lang="cpp"]<br
/> #include<br
/> using namespace std;</p><p>void report(string label, int i, int j, int k)<br
/> {<br
/> cout &lt;&lt; label &lt;&lt; &quot; i:&quot; &lt;&lt; i &lt;&lt; &quot; j: &quot; &lt;&lt; j &lt;&lt; &quot; k: &quot; &lt;&lt; k &lt;&lt; endl;<br
/> }</p><p>int main ()<br
/> {<br
/> int i = 123;<br
/> int j = 456;<br
/> int k = 789;</p><p> report(&quot;before loop&quot;, i, j, k);<br
/> cout &lt;&lt; endl;</p><p> // inner scope i hides outer scope i<br
/> for (int i = 0; i &lt; 2; i++)<br
/> {<br
/> // inner scope j hides outer scope j<br
/> // outer scope k not hidden<br
/> int j = i;<br
/> report(&quot;in for loop&quot;, i, j, k);<br
/> }<br
/> cout &lt;&lt; endl;<br
/> report(&quot;after loop &quot;, i, j, k);<br
/> return 0;<br
/> }<br
/> [/code]</p><p>output:</p><p>[bash] &gt; g++ -Wall -o scope for_loop_scope.cpp<br
/> &gt; ./scope<br
/> before loop i:123 j: 456 k: 789</p><p>in for loop i:0 j: 0 k: 789<br
/> in for loop i:1 j: 1 k: 789</p><p>after loop  i:123 j: 456 k: 789<br
/> [/bash]</p><p>Please leave a comment if you feel I&#8217;ve gotten something wrong here.<br
/> If your compiler does something different, I want to hear about it.</p><p>The post <a
href="http://variedthoughts.com/programming/c-variable-scope-for-loop/">C++ variable scope and the for loop</a> appeared first on <a
href="http://variedthoughts.com">Varied Thoughts</a>.</p>]]></content:encoded> <wfw:commentRss>http://variedthoughts.com/programming/c-variable-scope-for-loop/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Compiling C++ code on the command line</title><link>http://variedthoughts.com/programming/compiling-cpp-command-line/</link> <comments>http://variedthoughts.com/programming/compiling-cpp-command-line/#comments</comments> <pubDate>Tue, 20 Mar 2012 18:04:41 +0000</pubDate> <dc:creator>Brian</dc:creator> <category><![CDATA[Programming]]></category> <category><![CDATA[c++]]></category> <category><![CDATA[command line]]></category> <category><![CDATA[cygwin]]></category> <category><![CDATA[g++]]></category> <category><![CDATA[gpp]]></category> <category><![CDATA[stdlib]]></category><guid isPermaLink="false">http://variedthoughts.com/?p=280</guid> <description><![CDATA[<p>Quick instructions for compiling small C++ projects on the command line in bash. My normal development environment is to edit in Vim, and compile in a Visual Studio project. However, I occasionally have an idea that I&#8217;d like to test out by itself, isolated from the rest of the code. My usual solution is to [...]</p><p>The post <a
href="http://variedthoughts.com/programming/compiling-cpp-command-line/">Compiling C++ code on the command line</a> appeared first on <a
href="http://variedthoughts.com">Varied Thoughts</a>.</p>]]></description> <content:encoded><![CDATA[<p>Quick instructions for compiling small C++ projects on the command line in bash.<br
/> <span
id="more-280"></span><br
/> My normal development environment is to edit in Vim, and compile in a Visual Studio project.</p><p>However, I occasionally have an idea that I&#8217;d like to test out by itself, isolated from the rest of the code.<br
/> My usual solution is to write a small test program and compile it on the command line, debugging with writes to the output stream.</p><p>As an example, I recently wanted to refresh my memory about how string::find works.<br
/> I saw an example program at <a
href="http://www.cplusplus.com/reference/string/string/find/">cplusplus.com</a></p><p>So to start, I just grabbed the example and saved it to string_find.cpp.</p><p>Now to compile it.<br
/> Hmmm.<br
/> First attempt:</p><p>[bash]<br
/> gcc -o string_find string_find.cpp<br
/> &#8230; massive list of errors omitted &#8230;<br
/> [/bash]</p><p>Well, that wasn&#8217;t it.</p><p>Look it up somewhere, can&#8217;t remember where, probably on <a
href="http://stackoverflow.com">stackoverflow</a>.</p><p>Here&#8217;s what I want:</p><p>[bash]<br
/> g++ -Wall -o string_find string_find.cpp<br
/> &gt; ./string_find.exe<br
/> first &#8216;needle&#8217; found at: 14<br
/> second &#8216;needle&#8217; found at: 44<br
/> &#8216;haystack&#8217; also found at: 30<br
/> Period found at: 51<br
/> There are two prepositions in this haystack with needles.<br
/> [/bash]</p><p>Awesome.<br
/> Now, post this to the blog so I don&#8217;t have to look it up again.<br
/> Whew!</p><p>Turns out that the gcc command will try to compile c++ code, but doesn&#8217;t link the standard library.<br
/> However, g++ does include the standard library, so stuff like are available.</p><p>The post <a
href="http://variedthoughts.com/programming/compiling-cpp-command-line/">Compiling C++ code on the command line</a> appeared first on <a
href="http://variedthoughts.com">Varied Thoughts</a>.</p>]]></content:encoded> <wfw:commentRss>http://variedthoughts.com/programming/compiling-cpp-command-line/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> </channel> </rss><!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: basic

Served from: variedthoughts.com @ 2013-05-12 18:26:51 -->
