<?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>Proguru &#124; IT tech,review and news &#187; C/C++/Asm</title>
	<atom:link href="http://blog.pcware.cn/category/it/lang/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.pcware.cn</link>
	<description>Just for Freedom</description>
	<lastBuildDate>Thu, 29 Jul 2010 06:35:03 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>C++项目目录组织结构</title>
		<link>http://blog.pcware.cn/it/lang/cpp_project_directories.html</link>
		<comments>http://blog.pcware.cn/it/lang/cpp_project_directories.html#comments</comments>
		<pubDate>Sun, 16 May 2010 07:40:02 +0000</pubDate>
		<dc:creator>proguru</dc:creator>
				<category><![CDATA[C/C++/Asm]]></category>

		<guid isPermaLink="false">http://blog.pcware.cn/?p=816</guid>
		<description><![CDATA[项目目录结构的问题基本上是个仁者见仁，智者见智的问题，只要自己用着顺手，使用什么样的目录组织结构是没有什么大碍的。当然如果项目很大，参与的人员很多，那么合理的组织一下目录结构还是会有很大的益处的。不同类型的项目也会有不同的目录结构,这里简单的展示一下我所使用的C++项目的基本目录结构。
project &#8212;+&#8212;build&#8212;+&#8212;debug
　　　　　&#124;　　　　　&#124;&#8212;release
　　　　　&#124;&#8212;dist
　　　　　&#124;&#8212;doc
　　　　　&#124;&#8212;include&#8212;+&#8212;module1
　　　　　&#124;　　　　　　&#124;&#8212;module2
　　　　　&#124;&#8212;lib
　　　　　&#124;&#8212;module1
　　　　　&#124;&#8212;module2
　　　　　&#124;&#8212;res
　　　　　&#124;&#8212;samples&#8212;+&#8212;sample1
　　　　　&#124;　　　　　　&#124;&#8212;sample2
　　　　　&#124;&#8212;tools
　　　　　&#124;&#8212;copyleft
　　　　　&#124;&#8212;Makefile
　　　　　&#124;&#8212;README
　　　　　&#124;&#8212; &#8230;

下面分别介绍一下各目录和文件的用途
build/:项目编译目录，各种编译的临时文件和最终的目标文件皆存于此，分为debug/和release/子目录
dist/:分发目录，最终发布的可执行程序和各种运行支持文件存放在此目录，打包此目录即可完成项目分发
doc/:保存项目各种文档
include/:公共头文件目录，可以按模块划分组织目录来保存模块相关头文件
lib/:外部依赖库目录
res/:资源目录
samples/:样例程序目录
tools/:项目支撑工具目录
copyleft:版权声明文件，当然也可以叫做copyright :-)
Makefile:项目构建配置文件，当然也有可能是其他类型的构建配置文件,比如bjam
README:项目的总体说明文件
]]></description>
			<content:encoded><![CDATA[<p style="text-indent:2em">项目目录结构的问题基本上是个仁者见仁，智者见智的问题，只要自己用着顺手，使用什么样的目录组织结构是没有什么大碍的。当然如果项目很大，参与的人员很多，那么合理的组织一下目录结构还是会有很大的益处的。不同类型的项目也会有不同的目录结构,这里简单的展示一下我所使用的C++项目的基本目录结构。</p>
<p>project &#8212;+&#8212;build&#8212;+&#8212;debug<br />
　　　　　|　　　　　|&#8212;release<br />
　　　　　|&#8212;dist<br />
　　　　　|&#8212;doc<br />
　　　　　|&#8212;include&#8212;+&#8212;module1<br />
　　　　　|　　　　　　|&#8212;module2<br />
　　　　　|&#8212;lib<br />
　　　　　|&#8212;module1<br />
　　　　　|&#8212;module2<br />
　　　　　|&#8212;res<br />
　　　　　|&#8212;samples&#8212;+&#8212;sample1<br />
　　　　　|　　　　　　|&#8212;sample2<br />
　　　　　|&#8212;tools<br />
　　　　　|&#8212;copyleft<br />
　　　　　|&#8212;Makefile<br />
　　　　　|&#8212;README<br />
　　　　　|&#8212; &#8230;<br />
<span id="more-816"></span></p>
<p style="text-indent:2em">下面分别介绍一下各目录和文件的用途</p>
<p style="text-indent:2em">build/:项目编译目录，各种编译的临时文件和最终的目标文件皆存于此，分为debug/和release/子目录</p>
<p style="text-indent:2em">dist/:分发目录，最终发布的可执行程序和各种运行支持文件存放在此目录，打包此目录即可完成项目分发</p>
<p style="text-indent:2em">doc/:保存项目各种文档</p>
<p style="text-indent:2em">include/:公共头文件目录，可以按模块划分组织目录来保存模块相关头文件</p>
<p style="text-indent:2em">lib/:外部依赖库目录</p>
<p style="text-indent:2em">res/:资源目录</p>
<p style="text-indent:2em">samples/:样例程序目录</p>
<p style="text-indent:2em">tools/:项目支撑工具目录</p>
<p style="text-indent:2em">copyleft:版权声明文件，当然也可以叫做copyright :-)</p>
<p style="text-indent:2em">Makefile:项目构建配置文件，当然也有可能是其他类型的构建配置文件,比如bjam</p>
<p style="text-indent:2em">README:项目的总体说明文件</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.pcware.cn/it/lang/cpp_project_directories.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>C/C++ static语义(semantics)</title>
		<link>http://blog.pcware.cn/it/lang/static_semantics.html</link>
		<comments>http://blog.pcware.cn/it/lang/static_semantics.html#comments</comments>
		<pubDate>Wed, 18 Nov 2009 03:00:21 +0000</pubDate>
		<dc:creator>proguru</dc:creator>
				<category><![CDATA[C/C++/Asm]]></category>

		<guid isPermaLink="false">http://blog.pcware.cn/?p=626</guid>
		<description><![CDATA[　　static可以用来修饰变量(variant)和函数(function)。但static作用于普通变量/函数与类(calss)变量/函数的语义是不一样的。
　　static有两种基本的语义，第一种是存储方式(storage)，这种语义只作用于变量，不适用于函数，第二种是访问控制(Access Control)。
　　用static修饰一个普通变量有两层含义。其一是表示该变量的值在超出作用域范围后仍然有效，一般编译器将static变量放置到全局静态存储区，比如.data或.bss(Block Started by Symbol)节，这就是存储方式语义。其二是表示该变量只在声明的作用域范围内可以被访问，比如， 声明在一个文件作用域内的变量不能被其他文件访问，这就是访问控制语义。
　　用static来修饰普通函数的时候则只有一种语义，即访问控制，因为无论如何，函数总是要被编译器放置到.text节的。也就是说用static修饰的普通函数不能被其他文件内的代码访问。
　　C++中用static来修饰成员变量和函数的语义稍有不同，其含义表示这些变量或函数是属于整个类(class)而不特定于任何一个该类的对象(object),即使该类没有一个对象产生，仍然可用使用类来访问这些变量和函数。这是C++对C static语义的扩展。
]]></description>
			<content:encoded><![CDATA[<p>　　static可以用来修饰变量(variant)和函数(function)。但static作用于普通变量/函数与类(calss)变量/函数的语义是不一样的。<br />
　　static有两种基本的语义，第一种是存储方式(storage)，这种语义只作用于变量，不适用于函数，第二种是访问控制(Access Control)。<br />
　　用static修饰一个普通变量有两层含义。其一是表示该变量的值在超出作用域范围后仍然有效，一般编译器将static变量放置到全局静态存储区，比如.data或.bss(Block Started by Symbol)节，这就是存储方式语义。其二是表示该变量只在声明的作用域范围内可以被访问，比如， 声明在一个文件作用域内的变量不能被其他文件访问，这就是访问控制语义。<br />
　　用static来修饰普通函数的时候则只有一种语义，即访问控制，因为无论如何，函数总是要被编译器放置到.text节的。也就是说用static修饰的普通函数不能被其他文件内的代码访问。<br />
　　C++中用static来修饰成员变量和函数的语义稍有不同，其含义表示这些变量或函数是属于整个类(class)而不特定于任何一个该类的对象(object),即使该类没有一个对象产生，仍然可用使用类来访问这些变量和函数。这是C++对C static语义的扩展。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.pcware.cn/it/lang/static_semantics.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>关于C和C++的布尔类型,_Bool和bool</title>
		<link>http://blog.pcware.cn/it/lang/_bool_and_bool.html</link>
		<comments>http://blog.pcware.cn/it/lang/_bool_and_bool.html#comments</comments>
		<pubDate>Thu, 04 Jun 2009 14:28:13 +0000</pubDate>
		<dc:creator>proguru</dc:creator>
				<category><![CDATA[C/C++/Asm]]></category>

		<guid isPermaLink="false">http://blog.pcware.cn/?p=82</guid>
		<description><![CDATA[C++内置对布尔类型的支持，其关键字是bool，C语言直到C99标准才增加了对布尔类型的支持，关键字为_Bool，因为bool已经被C++ 用了，所以选了这个十分奇怪的关键字。在这之前C程序员对布尔类型的模拟是相当混乱的。为了在C和C++程序中以统一的方式使用布尔类型，同时提高可移植性，可以采用下面的方式:

构造一个stdbool.h头文件定义相关的宏，内容如下：
&#160;1 /*&#160;
&#160;2 &#160;* stdbool.h
&#160;3 &#160;* boolean macros for C
&#160;4 &#160;*/
&#160;5 
&#160;6 #ifndef __STDBOOL_H__
&#160;7 #define __STDBOOL_H__
&#160;8 
&#160;9 #ifndef __cplusplus
10 
11 #undef bool
12 #undef true
13 #undef false
14 
15 #define true&#160;&#160;&#160;&#160;1
16 #define false&#160;&#160; 0
17 
18 #if __STDC_VERSION__ &#60; 199901L
19 typedef&#160;int&#160;_Bool
20 #endif&#160;//__STDC_VERSION__
21 #define bool&#160;_Bool
22 
23 #define __bool_true_false_are_defined 1
24 
25 #endif&#160;//__cplusplus
26 
27 #endif&#160;//__STDBOOL_H__
然后在要使用布尔类型的文件里包含这个头文件，
 #include “stdbool.h”
就可以统一按bool来表达布尔类型了。
P.S. 目前仍然有很多编译器并不支持C99的新特性，特别是比较老的编译器，如CB6和VC6都不支持_Bool关键字
&#8212;
PS:此文最早发表于CSDN.
]]></description>
			<content:encoded><![CDATA[<p>C++内置对布尔类型的支持，其关键字是bool，C语言直到C99标准才增加了对布尔类型的支持，关键字为_Bool，因为bool已经被C++ 用了，所以选了这个十分奇怪的关键字。在这之前C程序员对布尔类型的模拟是相当混乱的。为了在C和C++程序中以统一的方式使用布尔类型，同时提高可移植性，可以采用下面的方式:<br />
<span id="more-82"></span><br />
构造一个stdbool.h头文件定义相关的宏，内容如下：<br />
<font color="#a52a2a">&nbsp;1 </font><font color="#0000ff">/*</font><font color="#0000ff">&nbsp;</font><br />
<font color="#a52a2a">&nbsp;2 </font><font color="#0000ff">&nbsp;* stdbool.h</font><br />
<font color="#a52a2a">&nbsp;3 </font><font color="#0000ff">&nbsp;* boolean macros for C</font><br />
<font color="#a52a2a">&nbsp;4 </font><font color="#0000ff">&nbsp;</font><font color="#0000ff">*/</font><br />
<font color="#a52a2a">&nbsp;5 </font><br />
<font color="#a52a2a">&nbsp;6 </font><font color="#a020f0">#ifndef __STDBOOL_H__</font><br />
<font color="#a52a2a">&nbsp;7 </font><font color="#a020f0">#define __STDBOOL_H__</font><br />
<font color="#a52a2a">&nbsp;8 </font><br />
<font color="#a52a2a">&nbsp;9 </font><font color="#a020f0">#ifndef __cplusplus</font><br />
<font color="#a52a2a">10 </font><br />
<font color="#a52a2a">11 </font><font color="#a020f0">#undef </font><font color="#2e8b57"><b>bool</b></font><br />
<font color="#a52a2a">12 </font><font color="#a020f0">#undef </font><font color="#ff00ff">true</font><br />
<font color="#a52a2a">13 </font><font color="#a020f0">#undef </font><font color="#ff00ff">false</font><br />
<font color="#a52a2a">14 </font><br />
<font color="#a52a2a">15 </font><font color="#a020f0">#define </font><font color="#ff00ff">true</font><font color="#a020f0">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#ff00ff">1</font><br />
<font color="#a52a2a">16 </font><font color="#a020f0">#define </font><font color="#ff00ff">false</font><font color="#a020f0">&nbsp;&nbsp; </font><font color="#ff00ff">0</font><br />
<font color="#a52a2a">17 </font><br />
<font color="#a52a2a">18 </font><font color="#a020f0">#if __STDC_VERSION__ &lt; </font><font color="#ff00ff">199901L</font><br />
<font color="#a52a2a">19 </font><font color="#2e8b57"><b>typedef</b></font>&nbsp;<font color="#2e8b57"><b>int</b></font>&nbsp;_Bool<br />
<font color="#a52a2a">20 </font><font color="#a020f0">#endif</font>&nbsp;<font color="#0000ff">//__STDC_VERSION__</font><br />
<font color="#a52a2a">21 </font><font color="#a020f0">#define </font><font color="#2e8b57"><b>bool</b></font><font color="#a020f0">&nbsp;_Bool</font><br />
<font color="#a52a2a">22 </font><br />
<font color="#a52a2a">23 </font><font color="#a020f0">#define __bool_true_false_are_defined </font><font color="#ff00ff">1</font><br />
<font color="#a52a2a">24 </font><br />
<font color="#a52a2a">25 </font><font color="#a020f0">#endif</font>&nbsp;<font color="#0000ff">//__cplusplus</font><br />
<font color="#a52a2a">26 </font><br />
<font color="#a52a2a">27 </font><font color="#a020f0">#endif</font>&nbsp;<font color="#0000ff">//__STDBOOL_H__</font></p>
<p>然后在要使用布尔类型的文件里包含这个头文件，</p>
<p> #include “stdbool.h”</p>
<p>就可以统一按bool来表达布尔类型了。</p>
<p>P.S. 目前仍然有很多编译器并不支持C99的新特性，特别是比较老的编译器，如CB6和VC6都不支持_Bool关键字</p>
<p>&#8212;</p>
<p>PS:<a href="http://blog.csdn.net/mopyman/archive/2006/03/09/619564.aspx" target="_blank">此文</a>最早发表于CSDN.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.pcware.cn/it/lang/_bool_and_bool.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Visual C++ 2008 Express编译boost 1.39 regex库遇到的问题及解决办法</title>
		<link>http://blog.pcware.cn/it/lang/boost_1_39_regex_solutions.html</link>
		<comments>http://blog.pcware.cn/it/lang/boost_1_39_regex_solutions.html#comments</comments>
		<pubDate>Mon, 01 Jun 2009 03:06:31 +0000</pubDate>
		<dc:creator>proguru</dc:creator>
				<category><![CDATA[C/C++/Asm]]></category>

		<guid isPermaLink="false">http://blog.pcware.cn/?p=60</guid>
		<description><![CDATA[最近在玩boost,用vc++ 2008 express编译最新版本1.39时遇到一点小问题，记录于此。
分别下载了zlib,bzip2和icu，python暂时不玩，没接触过。我喜欢静态链接程序，根据官方文档的提示，在console输入如下指令，为了输入方便，最好写个bat脚本：
bootstrap
bjam  -sBZIP2_SOURCE=D:/libs/bzip2-1.0.5 -sZLIB_SOURCE=D:/libs/zlib-1.2.3 -sHAVE_ICU=1 -sICU_PATH=D:/libs/icu link=static runtime-link=static threading=multi &#8211;without-python
console窗口一阵晃动后吐出了这么三行error:
error: link=shared together with runtime-link=static is not allowed
error: such property combination is either impossible
error: or too dangerious to be of any use
百思不得其解，明明我的link选项只有static，哪来的shared啊，郁闷啊郁闷，反复折腾后，发现，如果没有ICU选项，则不会出现此错误提示。
用vim打开boost_1_39_0\libs\regex\build\jamfile.v2,搜索一下/\&#60;shared\&#62;，果然在文件底部，218,223和229行链接选项被写死为shared。那就去掉这该死的shared，重新来过，bjam终于开始正常工作了。
编译带ICU选项的regex还会遇到一点儿小问题。boost.regex期望的icui18n.lib和icudata.lib与编译后的ICU库的名字并不相同，简单修改一下就可以了,如下：
libs\icu\lib\icuin.lib -&#62; icui18n.lib
libs\icu\lib\icudt.lib -&#62; icudata.lib
测试了boost 1.39官方文档的regex测试程序，静态链接，一切OK。
]]></description>
			<content:encoded><![CDATA[<p>最近在玩boost,用vc++ 2008 express编译最新版本1.39时遇到一点小问题，记录于此。<br />
分别下载了zlib,bzip2和icu，python暂时不玩，没接触过。我喜欢静态链接程序，根据官方文档的提示，在console输入如下指令，为了输入方便，最好写个bat脚本：</p>
<p>bootstrap<br />
bjam  -sBZIP2_SOURCE=D:/libs/bzip2-1.0.5 -sZLIB_SOURCE=D:/libs/zlib-1.2.3 -sHAVE_ICU=1 -sICU_PATH=D:/libs/icu link=static runtime-link=static threading=multi &#8211;without-python</p>
<p>console窗口一阵晃动后吐出了这么三行error:</p>
<p>error: link=shared together with runtime-link=static is not allowed<br />
error: such property combination is either impossible<br />
error: or too dangerious to be of any use</p>
<p>百思不得其解，明明我的link选项只有static，哪来的shared啊，郁闷啊郁闷，反复折腾后，发现，如果没有ICU选项，则不会出现此错误提示。</p>
<p>用vim打开boost_1_39_0\libs\regex\build\jamfile.v2,搜索一下/\&lt;shared\&gt;，果然在文件底部，218,223和229行链接选项被写死为shared。那就去掉这该死的shared，重新来过，bjam终于开始正常工作了。</p>
<p>编译带ICU选项的regex还会遇到一点儿小问题。boost.regex期望的icui18n.lib和icudata.lib与编译后的ICU库的名字并不相同，简单修改一下就可以了,如下：<br />
libs\icu\lib\icuin.lib -&gt; icui18n.lib<br />
libs\icu\lib\icudt.lib -&gt; icudata.lib</p>
<p>测试了boost 1.39官方文档的regex测试程序，静态链接，一切OK。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.pcware.cn/it/lang/boost_1_39_regex_solutions.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
