﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>C++博客-技术笔记——Beyond Programming-随笔分类-磨刀不误砍柴工</title><link>http://www.cppblog.com/archiveman/category/13204.html</link><description>欢迎喜欢技术的朋友来转转</description><language>zh-cn</language><lastBuildDate>Sun, 20 Jun 2010 15:15:09 GMT</lastBuildDate><pubDate>Sun, 20 Jun 2010 15:15:09 GMT</pubDate><ttl>60</ttl><item><title>GNU C/C＋＋简易编译支持脚本</title><link>http://www.cppblog.com/archiveman/archive/2010/06/20/118291.html</link><dc:creator>David Fang</dc:creator><author>David Fang</author><pubDate>Sun, 20 Jun 2010 03:50:00 GMT</pubDate><guid>http://www.cppblog.com/archiveman/archive/2010/06/20/118291.html</guid><wfw:comment>http://www.cppblog.com/archiveman/comments/118291.html</wfw:comment><comments>http://www.cppblog.com/archiveman/archive/2010/06/20/118291.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/archiveman/comments/commentRss/118291.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/archiveman/services/trackbacks/118291.html</trackback:ping><description><![CDATA[看了Unix原理和应用，也是为了平时写些小程序，小例子方便，特别制作了一个易用的辅助脚本，脚本文件compile.sh如下：<br>
<div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #000000;">#</span><span style="color: #000000;">!/</span><span style="color: #000000;">bin</span><span style="color: #000000;">/</span><span style="color: #000000;">sh<br>#comc.sh:&nbsp;script&nbsp;that&nbsp;helps&nbsp;programming&nbsp;</span><span style="color: #0000ff;">in</span><span style="color: #000000;">&nbsp;C</span><span style="color: #000000;">/</span><span style="color: #000000;">C</span><span style="color: #000000;">++</span><span style="color: #000000;"><br>#author:Don<br><br>sources</span><span style="color: #000000;">=</span><span style="color: #000000;">`ls&nbsp;</span><span style="color: #000000;">-</span><span style="color: #000000;">t&nbsp;</span><span style="color: #000000;">*</span><span style="color: #000000;">.c&nbsp;</span><span style="color: #000000;">*</span><span style="color: #000000;">.cpp&nbsp;</span><span style="color: #000000;">*</span><span style="color: #000000;">.cxx&nbsp;</span><span style="color: #000000;">*</span><span style="color: #000000;">.h&nbsp;</span><span style="color: #000000;">2</span><span style="color: #000000;">&gt;/</span><span style="color: #000000;">dev</span><span style="color: #000000;">/</span><span style="color: #0000ff;">null</span><span style="color: #000000;">`<br>lastsource</span><span style="color: #000000;">=</span><span style="color: #000000;">`ls&nbsp;</span><span style="color: #000000;">-</span><span style="color: #000000;">t&nbsp;</span><span style="color: #000000;">*</span><span style="color: #000000;">.c&nbsp;</span><span style="color: #000000;">*</span><span style="color: #000000;">.cpp&nbsp;</span><span style="color: #000000;">*</span><span style="color: #000000;">.cxx&nbsp;</span><span style="color: #000000;">*</span><span style="color: #000000;">.h&nbsp;</span><span style="color: #000000;">2</span><span style="color: #000000;">&gt;/</span><span style="color: #000000;">dev</span><span style="color: #000000;">/</span><span style="color: #0000ff;">null</span><span style="color: #000000;">&nbsp;</span><span style="color: #000000;">|</span><span style="color: #000000;">&nbsp;head&nbsp;</span><span style="color: #000000;">-</span><span style="color: #000000;">n&nbsp;</span><span style="color: #000000;">1</span><span style="color: #000000;">`<br><br>command</span><span style="color: #000000;">=</span><span style="color: #000000;">$</span><span style="color: #000000;">0</span><span style="color: #000000;"><br>executable</span><span style="color: #000000;">=</span><span style="color: #000000;">"</span><span style="color: #000000;">${PWD##*/}</span><span style="color: #000000;">"</span><span style="color: #000000;"><br><br></span><span style="color: #0000ff;">case</span><span style="color: #000000;">&nbsp;$command&nbsp;</span><span style="color: #0000ff;">in</span><span style="color: #000000;"><br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #000000;">*</span><span style="color: #000000;">r)&nbsp;.</span><span style="color: #000000;">/</span><span style="color: #000000;">"</span><span style="color: #000000;">${executable}</span><span style="color: #000000;">"</span><span style="color: #000000;">&nbsp;</span><span style="color: #000000;">&lt;/</span><span style="color: #000000;">dev</span><span style="color: #000000;">/</span><span style="color: #000000;">tty&nbsp;</span><span style="color: #000000;">&gt;/</span><span style="color: #000000;">dev</span><span style="color: #000000;">/</span><span style="color: #000000;">tty&nbsp;</span><span style="color: #000000;">2</span><span style="color: #000000;">&gt;&amp;</span><span style="color: #000000;">1</span><span style="color: #000000;">&nbsp;;;<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #000000;">*</span><span style="color: #000000;">vc)&nbsp;vim&nbsp;$lastsource&nbsp;;;<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #000000;">*</span><span style="color: #000000;">vac)&nbsp;vim&nbsp;$sources&nbsp;;;<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #000000;">*</span><span style="color: #000000;">c)&nbsp;gcc&nbsp;</span><span style="color: #000000;">-</span><span style="color: #000000;">g&nbsp;</span><span style="color: #000000;">-</span><span style="color: #000000;">O0&nbsp;</span><span style="color: #000000;">-</span><span style="color: #000000;">o&nbsp;$executable&nbsp;$sources&nbsp;</span><span style="color: #000000;">&amp;&amp;</span><span style="color: #000000;">&nbsp;echo&nbsp;</span><span style="color: #000000;">"</span><span style="color: #000000;">gcc&nbsp;compiled&nbsp;successfully</span><span style="color: #000000;">"</span><span style="color: #000000;">;;<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #000000;">*</span><span style="color: #000000;">cxx)&nbsp;g</span><span style="color: #000000;">++</span><span style="color: #000000;">&nbsp;</span><span style="color: #000000;">-</span><span style="color: #000000;">g&nbsp;</span><span style="color: #000000;">-</span><span style="color: #000000;">O0&nbsp;</span><span style="color: #000000;">-</span><span style="color: #000000;">o&nbsp;$executable&nbsp;$sources&nbsp;</span><span style="color: #000000;">&amp;&amp;</span><span style="color: #000000;">&nbsp;echo&nbsp;</span><span style="color: #000000;">"</span><span style="color: #000000;">g++&nbsp;compiled&nbsp;successfully</span><span style="color: #000000;">"</span><span style="color: #000000;">;;<br>esac</span></div>
<br>放在任何目录下都可以：<br>然后添加连接到/usr/bin<br>
<div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #000000;">ln&nbsp;</span><span style="color: #000000;">/</span><span style="color: #000000;">path</span><span style="color: #000000;">/</span><span style="color: #000000;">to</span><span style="color: #000000;">/</span><span style="color: #000000;">compile.sh&nbsp;&nbsp;</span><span style="color: #000000;">/</span><span style="color: #000000;">usr</span><span style="color: #000000;">/</span><span style="color: #000000;">bin</span><span style="color: #000000;">/</span><span style="color: #000000;">r<br>ln&nbsp;</span><span style="color: #000000;">/</span><span style="color: #000000;">path</span><span style="color: #000000;">/</span><span style="color: #000000;">to</span><span style="color: #000000;">/</span><span style="color: #000000;">compile.sh&nbsp;&nbsp;</span><span style="color: #000000;">/</span><span style="color: #000000;">usr</span><span style="color: #000000;">/</span><span style="color: #000000;">bin</span><span style="color: #000000;">/</span><span style="color: #000000;">vc<br>ln&nbsp;</span><span style="color: #000000;">/</span><span style="color: #000000;">path</span><span style="color: #000000;">/</span><span style="color: #000000;">to</span><span style="color: #000000;">/</span><span style="color: #000000;">compile.sh&nbsp;&nbsp;</span><span style="color: #000000;">/</span><span style="color: #000000;">usr</span><span style="color: #000000;">/</span><span style="color: #000000;">bin</span><span style="color: #000000;">/</span><span style="color: #000000;">vac<br>ln&nbsp;</span><span style="color: #000000;">/</span><span style="color: #000000;">path</span><span style="color: #000000;">/</span><span style="color: #000000;">to</span><span style="color: #000000;">/</span><span style="color: #000000;">compile.sh&nbsp;&nbsp;</span><span style="color: #000000;">/</span><span style="color: #000000;">usr</span><span style="color: #000000;">/</span><span style="color: #000000;">bin</span><span style="color: #000000;">/</span><span style="color: #000000;">c<br>ln&nbsp;</span><span style="color: #000000;">/</span><span style="color: #000000;">path</span><span style="color: #000000;">/</span><span style="color: #000000;">to</span><span style="color: #000000;">/</span><span style="color: #000000;">compile.sh&nbsp;&nbsp;</span><span style="color: #000000;">/</span><span style="color: #000000;">usr</span><span style="color: #000000;">/</span><span style="color: #000000;">bin</span><span style="color: #000000;">/</span><span style="color: #000000;">cxx</span></div>
<br>这样写小程序时就能用下面的步骤了:<br>1.创建程序目录并切换到目录下<br>
<div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #000000;">mkdir&nbsp;example&nbsp;</span><span style="color: #000000;">&amp;&amp;</span><span style="color: #000000;">&nbsp;cd&nbsp;$_</span></div>
2.创建源码文件<br>
<div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #000000;">vim&nbsp;main.cpp</span></div>
3.编辑代码，保存<br>4.编译，如果是cpp代码则运行cxx，如果是c代码则运行c，生成的二进制可执行文件名称是程序坐在目录名称。<br>5.要重新编辑最后一个源文件则运行vc命令，要重新编辑所有源文件则运行vac命令。<br>6.编译成功后，要运行时运行r命令。<br><br>上面是我参考Unix原理于应用上的一个例子写出来的，最近在搞一些算法方面的题目，用这个脚本做些算法题和简单的测试程序还是比较实用的，当然如果要开发大型的软件，特别是要依赖标准库以外的东西，还是要靠Makefile.<br><img src ="http://www.cppblog.com/archiveman/aggbug/118291.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/archiveman/" target="_blank">David Fang</a> 2010-06-20 11:50 <a href="http://www.cppblog.com/archiveman/archive/2010/06/20/118291.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Lua小程序:十六进制字符串和二进制数据间的转换</title><link>http://www.cppblog.com/archiveman/archive/2010/03/30/111056.html</link><dc:creator>David Fang</dc:creator><author>David Fang</author><pubDate>Tue, 30 Mar 2010 14:20:00 GMT</pubDate><guid>http://www.cppblog.com/archiveman/archive/2010/03/30/111056.html</guid><wfw:comment>http://www.cppblog.com/archiveman/comments/111056.html</wfw:comment><comments>http://www.cppblog.com/archiveman/archive/2010/03/30/111056.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/archiveman/comments/commentRss/111056.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/archiveman/services/trackbacks/111056.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 最近玩了一下Lua，写了一个小程序，用于实践十六进制字符串和二进制数据之间的转换。<br>主要是因为最近有这方面的需要（在搞一些 RSA加密的东西）。&nbsp;&nbsp;<a href='http://www.cppblog.com/archiveman/archive/2010/03/30/111056.html'>阅读全文</a><img src ="http://www.cppblog.com/archiveman/aggbug/111056.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/archiveman/" target="_blank">David Fang</a> 2010-03-30 22:20 <a href="http://www.cppblog.com/archiveman/archive/2010/03/30/111056.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>在内存中解压-实用gzip解压类封装</title><link>http://www.cppblog.com/archiveman/archive/2010/03/05/108983.html</link><dc:creator>David Fang</dc:creator><author>David Fang</author><pubDate>Fri, 05 Mar 2010 09:51:00 GMT</pubDate><guid>http://www.cppblog.com/archiveman/archive/2010/03/05/108983.html</guid><wfw:comment>http://www.cppblog.com/archiveman/comments/108983.html</wfw:comment><comments>http://www.cppblog.com/archiveman/archive/2010/03/05/108983.html#Feedback</comments><slash:comments>3</slash:comments><wfw:commentRss>http://www.cppblog.com/archiveman/comments/commentRss/108983.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/archiveman/services/trackbacks/108983.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: zlib的使用一般是以文件作为输入输出，而本类在zlib库基础上进行了一层封装，以便在内存中解压gzip数据，&nbsp;&nbsp;<a href='http://www.cppblog.com/archiveman/archive/2010/03/05/108983.html'>阅读全文</a><img src ="http://www.cppblog.com/archiveman/aggbug/108983.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/archiveman/" target="_blank">David Fang</a> 2010-03-05 17:51 <a href="http://www.cppblog.com/archiveman/archive/2010/03/05/108983.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>VI/VIM使用小技巧</title><link>http://www.cppblog.com/archiveman/archive/2010/03/05/108970.html</link><dc:creator>David Fang</dc:creator><author>David Fang</author><pubDate>Fri, 05 Mar 2010 07:31:00 GMT</pubDate><guid>http://www.cppblog.com/archiveman/archive/2010/03/05/108970.html</guid><wfw:comment>http://www.cppblog.com/archiveman/comments/108970.html</wfw:comment><comments>http://www.cppblog.com/archiveman/archive/2010/03/05/108970.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/archiveman/comments/commentRss/108970.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/archiveman/services/trackbacks/108970.html</trackback:ping><description><![CDATA[1.打开文件时自动回到上次关闭时的位置
<br>
<div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>-->au&nbsp;BufReadPost&nbsp;*&nbsp;if&nbsp;line("'\"")&nbsp;&gt;&nbsp;0|if&nbsp;line("'\"")&nbsp;&lt;=&nbsp;line("$")|exe("norm&nbsp;'\"")|else|exe&nbsp;"norm&nbsp;$"|endif|endif</div>
注意单引号和双引号
<br>2.在普通模式下输入Enter键时也能换行（不用切换到插入模式然后换行然后又切回普通模式这么麻烦的） <br>
<div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>-->:nmap&nbsp;&lt;Enter&gt;&nbsp;i&lt;Enter&gt;&lt;ESC&gt;</div>
或
<br>
<div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>-->:nmap&nbsp;&lt;CR&gt;&nbsp;i&lt;Enter&gt;&lt;ESC&gt;</div>
或
<br>
<div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>-->:nmap&nbsp;&lt;Enter&gt;&nbsp;ylpr&lt;Enter&gt;</div>
<br><img src ="http://www.cppblog.com/archiveman/aggbug/108970.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/archiveman/" target="_blank">David Fang</a> 2010-03-05 15:31 <a href="http://www.cppblog.com/archiveman/archive/2010/03/05/108970.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>