├── .gitignore
├── README.md
├── documents
├── C++找Bug训练.xmind
└── References.md
├── exports
└── C++找Bug训练.png
├── mds
├── C++常见问题.md
├── C++找bug训练.md
└── bugs
│ ├── bug101.md
│ ├── bug102.md
│ ├── bug201.md
│ ├── bug401.md
│ ├── bug403.md
│ ├── bug542.md
│ ├── bug602.md
│ └── bug604.md
└── source
├── Debug
└── gltop_bug2.pdb
├── bug101
└── source
│ └── main.cpp
├── bug102
└── source
│ └── main.cpp
├── bug1536
├── config
│ └── xcode
│ │ └── bug1536.xcodeproj
│ │ └── project.pbxproj
└── source
│ ├── bug1536.1
│ └── main.cpp
├── bug201
└── source
│ └── main.cpp
├── bug401
└── source
│ └── main.cpp
├── bug403
└── source
│ └── main.cpp
├── bug542
├── config
│ ├── vc2010
│ │ ├── bug542.vcxproj
│ │ └── bug542.vcxproj.filters
│ └── xcode
│ │ └── bug542.xcodeproj
│ │ └── project.pbxproj
└── source
│ ├── bug542.1
│ └── main.cpp
├── bug601
└── source
│ └── main.cpp
├── bug602
├── config
│ ├── vc2010
│ │ ├── bug602.vcxproj
│ │ └── bug602.vcxproj.filters
│ └── xcode
│ │ └── bug602.xcodeproj
│ │ └── project.pbxproj
└── source
│ ├── bug602.1
│ └── main.cpp
├── bug603
├── config
│ └── xcode
│ │ └── bug603.xcodeproj
│ │ └── project.pbxproj
└── source
│ ├── bug603.1
│ └── main.cpp
├── bug604
└── source
│ └── main.cpp
├── cpp_samples.sln
├── cpp_training.xcworkspace
└── contents.xcworkspacedata
├── gltop_bug1
├── config
│ ├── vc2010
│ │ ├── gltop_bug1.vcxproj
│ │ └── gltop_bug1.vcxproj.filters
│ └── xcode
│ │ └── gltop_bug1.xcodeproj
│ │ └── project.pbxproj
└── source
│ ├── gltop_bug1.1
│ └── main.cpp
└── gltop_bug2
├── config
├── vc2010
│ ├── Debug
│ │ ├── CL.read.1.tlog
│ │ ├── CL.write.1.tlog
│ │ ├── cl.command.1.tlog
│ │ ├── gltop_bug2.exe.embed.manifest
│ │ ├── gltop_bug2.exe.embed.manifest.res
│ │ ├── gltop_bug2.exe.intermediate.manifest
│ │ ├── gltop_bug2.lastbuildstate
│ │ ├── gltop_bug2.log
│ │ ├── gltop_bug2_manifest.rc
│ │ ├── link-cvtres.read.1.tlog
│ │ ├── link-cvtres.write.1.tlog
│ │ ├── link.command.1.tlog
│ │ ├── link.read.1.tlog
│ │ ├── link.write.1.tlog
│ │ ├── mt.command.1.tlog
│ │ ├── mt.read.1.tlog
│ │ ├── mt.write.1.tlog
│ │ ├── rc.command.1.tlog
│ │ ├── rc.read.1.tlog
│ │ ├── rc.write.1.tlog
│ │ ├── vc100.idb
│ │ └── vc100.pdb
│ ├── gltop_bug2.vcxproj
│ └── gltop_bug2.vcxproj.filters
└── xcode
│ └── gltop_bug2.xcodeproj
│ └── project.pbxproj
└── source
├── gltop_bug2.1
└── main.cpp
/.gitignore:
--------------------------------------------------------------------------------
1 | # Prerequisites
2 | *.d
3 |
4 | # Compiled Object files
5 | *.slo
6 | *.lo
7 | *.o
8 | *.obj
9 |
10 | # Precompiled Headers
11 | *.gch
12 | *.pch
13 |
14 | # Compiled Dynamic libraries
15 | *.so
16 | *.dylib
17 | *.dll
18 |
19 | # Fortran module files
20 | *.mod
21 | *.smod
22 |
23 | # Compiled Static libraries
24 | *.lai
25 | *.la
26 | *.a
27 | *.lib
28 |
29 | # Executables
30 | *.exe
31 | *.out
32 | *.app
33 | source/bug1536/config/xcode/bug1536.xcodeproj/xcuserdata
34 | source/bug542/config/xcode/bug542.xcodeproj/xcuserdata
35 | source/gltop_bug2/config/xcode/gltop_bug2.xcodeproj/xcuserdata
36 | source/bug602/config/xcode/bug602.xcodeproj/xcuserdata
37 | source/gltop_bug1/config/xcode/gltop_bug1.xcodeproj/xcuserdata
38 | source/bug603/config/xcode/bug603.xcodeproj/xcuserdata
39 | source/cpp_training.xcworkspace/xcuserdata
40 | source/ipch
41 | source/cpp_samples.sdf
42 | source/cpp_samples.suo
43 | source/cpp_samples.userprefs
44 | *.user
45 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # C++找Bug训练
2 | > C++训练,提供了一些C++测试代码,通过分析其中的bug,来了解C++语言的一些特性。
3 |
4 | 
5 |
6 | ## 详细内容
7 | * [Bug101 - 数组尺寸](./mds/bugs/bug101.md)
8 | * [Bug102 - 整数除法问题](./mds/bugs/bug102.md)
9 | * [Bug401 - 数组越界](./mds/bugs/bug102.md)
10 | * [Bug403 - 清空结构内存](./mds/bugs/bug403.md)
11 | * [Bug542 - 指定长度的整形数](./mds/bugs/bug542.md)
12 | * [Bug602 - 注释使用](./mds/bugs/bug602.md)
13 | * [Bug604 - 宏的使用](./mds/bugs/bug604.md)
14 | * [更多C++找bug训练](https://github.com/gonglei007/cpp-bugs-killer/blob/main/mds/C++找bug训练.md) - TODO: 整理并分开列出每个bug问题。
15 | * [更多C++常见问题](https://github.com/gonglei007/cpp-bugs-killer/blob/main/mds/C++常见问题.md) - 比如野指针、内存对齐。
16 |
17 | ## 快捷测试
18 | > 可以把main.cpp文件中的代码复制到OnlineGDB中运行测试。
19 | > [Online GDB](https://www.onlinegdb.com/online_c++_compiler) - 是一个C++在线编译调试工具。
20 |
21 | ## 交流讨论
22 | 欢迎进群、进讨论区交流。
23 |
24 | | | |
25 | | --- | -------- |
26 | | QQ群: | 242500383 [](https://qm.qq.com/cgi-bin/qm/qr?k=fy4Z65nE-5Jd1ay8FkJpDc9iPJyW3d38&jump_from=webapi) |
27 |
28 |
29 |
30 | ## 拓展阅读
31 | * [更多C++相关](https://github.com/gonglei007/GameDevMind/blob/main/mds/1.1.2.C++语言.md) - C++语言的一些特性。
32 |
--------------------------------------------------------------------------------
/documents/C++找Bug训练.xmind:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gonglei007/cpp-bugs-killer/190da7cfb42d332bc9a3c25729923ef2517a7e77/documents/C++找Bug训练.xmind
--------------------------------------------------------------------------------
/documents/References.md:
--------------------------------------------------------------------------------
1 | * [CS 2204 - Summer 2004 Program Bug Examples](https://courses.cs.vt.edu/~cs2204/summer2004/readings/bugexamples.htm)
2 | * [C/C++100个典型的Bugs](https://blog.csdn.net/huang1032895981/article/details/12831529)
3 | * [pvs studio warnings案例](https://pvs-studio.com/en/docs/warnings/)
4 | * [C, C++, C#, Java bad practices: learn how to make a good code by bad example](https://hownot2code.wordpress.com/)
5 |
--------------------------------------------------------------------------------
/exports/C++找Bug训练.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gonglei007/cpp-bugs-killer/190da7cfb42d332bc9a3c25729923ef2517a7e77/exports/C++找Bug训练.png
--------------------------------------------------------------------------------
/mds/C++常见问题.md:
--------------------------------------------------------------------------------
1 |
C++常见问题
2 |
3 | # 野指针怎么产生的
4 |
5 | ## 示例1
6 |
7 | ```
8 | int main(){
9 | int *myNum = new int(12);
10 | int *myOtherNum = myNum;
11 |
12 | delete myNum;
13 |
14 | cout << *myOtherNum << endl;
15 |
16 | return 0;
17 | }
18 | ```
19 |
20 | ## 示例2
21 |
22 | ```
23 | int* badFunction(){
24 | int num = 10;
25 | return #
26 | }
27 | int* stillBad(int n){
28 | n += 12;
29 | return &n;
30 | }
31 | int main(){
32 | int num = 12;
33 | int *myNum = badFunction();
34 | int *myOtherNum = stillBad(num);
35 |
36 | cout << *myNum << “, “;
37 | cout << *myOtherNum << endl;
38 |
39 | return 0;
40 | }
41 | ```
42 |
43 | # 内存对齐
44 |
45 | ## 示例1
46 |
47 | ### 代码
48 |
49 | ```
50 | #include
51 | using namespace std;
52 |
53 | struct X1
54 | {
55 | int i;//4个字节
56 | char c1;//1个字节
57 | char c2;//1个字节
58 | };
59 |
60 | struct X2
61 | {
62 | char c1;//1个字节
63 | int i;//4个字节
64 | char c2;//1个字节
65 | };
66 |
67 | struct X3
68 | {
69 | char c1;//1个字节
70 | char c2;//1个字节
71 | int i;//4个字节
72 | };
73 |
74 | int main()
75 | {
76 | cout<<"long "<C++找bug训练
2 |
3 | # 运算符
4 | ## Bug1
5 | ### 代码
6 | ```
7 | 如果 'pceltFetched' 不是一个空指针,该函数必须增加该指针指向的ULONG类型变量的值。
8 | 这段代码有什么问题?
9 | STDMETHODIMP CCustomAutoComplete::Next(..., ULONG *pceltFetched)
10 | {
11 | ...
12 | if (pceltFetched != NULL)
13 | *pceltFetched++;
14 | ...
15 | }
16 | ```
17 |
18 | ### 说明
19 | ```
20 | '++' 运算符的优先级高于 '*' 运算符的优先级(指针解引用)。该 "*pceltFetched++;" 行等同于下面的代码:
21 | TMP = pceltFetched + 1;
22 | *pceltFetched;
23 | pceltFetched = TMP;
24 | 实际上它仅仅增加了指针的值。
25 | 为使代码正确,我们必须添加括号:"(*pceltFetched)++;".
26 |
27 | ```
28 |
29 |
30 | # if流程控制
31 | ## Bug1
32 | ### 代码
33 | ```
34 | 这段代码有什么问题?
35 | void BCMenu::InsertSpaces(void)
36 | {
37 | if(IsLunaMenuStyle())
38 | if(!xp_space_accelerators) return;
39 | else
40 | if(!original_space_accelerators) return;
41 | ...
42 | }
43 | ```
44 |
45 | ### 说明
46 | ```
47 | // 我们希望的逻辑是
48 | if(IsLunaMenuStyle()) {
49 | if(!xp_space_accelerators) return;
50 | } else {
51 | if(!original_space_accelerators) return;
52 | }
53 |
54 | // 但实际逻辑是
55 | if(IsLunaMenuStyle())
56 | {
57 | if(!xp_space_accelerators) {
58 | return;
59 | } else {
60 | if(!original_space_accelerators) return;
61 | }
62 | }
63 |
64 |
65 | ```
66 |
67 | # loop流程控制
68 | ## Bug1
69 | ### 代码
70 | ```
71 | 这段代码有什么问题?
72 | bool equals( class1* val1, class2* val2 ) const{
73 | {
74 | ...
75 | size_t size = val1->size();
76 | ...
77 | while ( --size >= 0 ){
78 | if ( !comp(*itr1,*itr2) )
79 | return false;
80 | itr1++;
81 | itr2++;
82 | }
83 | ...
84 | }
85 | ```
86 |
87 | ### 说明
88 | ```
89 | // size变量是无符号类型的,所以(--size >= 0) 条件总为 true.
90 | 建议这样写
91 | for (size_t i = 0; i != size; i++){
92 | if ( !comp(*itr1,*itr2) )
93 | return false;
94 | itr1++;
95 | itr2++;
96 | }
97 |
98 | ```
99 |
100 | # 内存
101 | ## Bug1
102 | ### 代码
103 | ```
104 | class Complex
105 | {
106 | public:
107 | double real, imag;
108 | Complex();
109 | };
110 |
111 | Complex& operator+( Complex& a, Complex& b)
112 | {
113 | Complex *p = new Complex;
114 | p->real = a.real + b.real;
115 | p->imag = a.imag + b.imag;
116 | return *p;
117 | }
118 | ```
119 |
120 | ### 说明
121 | ```
122 | binary operator 'Symbol' returning a reference -- An
123 | operator-like function was found to be returning a reference.
124 | For example:
125 |
126 | X &operator+ ( X &, X & );
127 |
128 | This is almost always a bad idea. [12, Item 23]. You normally
129 | can't return a reference unless you allocate the object, but then
130 | who is going to delete it. The usual way this is declared is:
131 |
132 | X operator+ ( X &, X & );
133 | ```
134 |
135 |
136 |
--------------------------------------------------------------------------------
/mds/bugs/bug101.md:
--------------------------------------------------------------------------------
1 | 数组尺寸
2 |
3 | ## 找Bug
4 |
5 | ```cpp
6 | ID_INLINE mat3_t::mat3_t( float src[3][3] )
7 | {
8 | memcpy( mat, src, sizeof( src ) );
9 | }
10 | ```
11 |
12 | ## 说明
13 |
14 | 正确的写法如下:
15 |
16 | ```cpp
17 | ID_INLINE mat3_t::mat3_t( float (&src)[3][3] )
18 | {
19 | memcpy( mat, src, sizeof( src ) );
20 | }
21 | ```
22 |
23 | ---
24 | * [示例代码](../../source/bug101/source/main.cpp)
25 | ---
26 |
27 | ## 拓展阅读
28 | * [In C and C++ arrays are not passed by value](https://hownot2code.wordpress.com/2016/06/25/in-c-and-c-arrays-are-not-passed-by-value/)
--------------------------------------------------------------------------------
/mds/bugs/bug102.md:
--------------------------------------------------------------------------------
1 | 整数除法问题
2 |
3 | ## 找Bug
4 |
5 | ```cpp
6 | /**
7 | * 检查投票通过率是否超过2/3。
8 | */
9 | bool CheckVotePassed(int votes, int total)
10 | {
11 | const int votePassNumber = 2;
12 | const int voteTotalNum = 3;
13 | return votes/total > votePassNumber/voteTotalNum;
14 | }
15 | ```
16 |
17 | ## 说明
18 |
19 | 由于文字“2”和“3”都是整数类型,商也将是整数,因此为零。
20 | 就相当于在判断 votes/total > 0
21 |
22 | 修复此错误的正确方法是将其中一个操作数显式转换为浮点类型,例如:
23 | ```cpp
24 | return votes/total > tatic_cast(votePassNumber)/voteTotalNum;
25 | ```
26 | 或者改变votePassNumber和voteTotalNum的类型。
27 | ```cpp
28 | const float votePassNumber = 2.0f;
29 | const float voteTotalNum = 3.0f;
30 | ```
31 |
32 | ---
33 | * [示例代码](../../source/bug102/source/main.cpp)
34 | ---
35 |
36 | ## 拓展阅读
37 | * [V1064. The left operand of integer division is less than the right one. The result will always be zero.](https://pvs-studio.com/en/docs/warnings/v1064/)
--------------------------------------------------------------------------------
/mds/bugs/bug201.md:
--------------------------------------------------------------------------------
1 | 空字符串检查
2 |
3 | ## 找Bug
4 |
5 |
6 | ```cpp
7 | //TODO: 未完成,暂时跳过。
8 | char *CUT_CramMd5::GetClientResponse(LPCSTR ServerChallenge)
9 | {
10 | ...
11 | if (m_szPassword != NULL)
12 | {
13 | ...
14 | if (m_szPassword != '\0')
15 | {
16 | ...
17 | }
18 | }
19 | }
20 |
21 | ```
22 |
23 | ### 说明
24 | ```cpp
25 | //TODO: 未完成,暂时跳过。
26 | 此代码段的意图是:确保指针m_szPassword不是空指针,并且其内容也不是空字符串。
27 | “if (m_szPassword != ‘\0’) ”是要检查字符串的第一个字符不是结束符。
28 | 应该写成“if (*m_szPassword != ‘\0’) ”
29 | ```
30 |
31 | ---
32 | * [示例代码](../../source/bug201/source/main.cpp)
33 | ---
34 |
35 | ## 拓展阅读
36 | * [100 bugs in Open Source C/C++ projects](https://pvs-studio.com/en/blog/posts/cpp/a0079/)
37 |
--------------------------------------------------------------------------------
/mds/bugs/bug401.md:
--------------------------------------------------------------------------------
1 | 数组越界
2 |
3 | ## 找Bug
4 | 这段代码来自于曾经的 Wolfenstein 3D项目 – 看看它有什么问题?
5 |
6 | ```cpp
7 | typedef struct bot_state_s
8 | {
9 | ...
10 | char teamleader[32];
11 | ...
12 | }bot_state_t;
13 |
14 | void BotTeamAI( bot_state_t* bs ){
15 | ...
16 | bs->teamleader[sizeof( bs->teamleader )] = '\0';
17 | ...
18 | }
19 | ```
20 |
21 |
22 | ### 说明
23 | "sizeof( bs->teamleader )]"这行的结果值已经超出了数组的最大边界,也就是写内存越界了。正确的写法如下:
24 | 首先,至少要用
25 | ```cpp
26 | sizeof(bs->teamleader) – 1
27 | ```
28 |
29 | 最好这样写,这样写在数组类型改为其它类型时也不会出错:
30 | ```cpp
31 | bs->teamleader[sizeof(bs->teamleader) / sizeof(bs->teamleader[0])-1] = ‘\0’;
32 | ```
33 |
34 | ---
35 | * [示例代码](../../source/bug401/source/main.cpp)
36 | ---
37 |
--------------------------------------------------------------------------------
/mds/bugs/bug403.md:
--------------------------------------------------------------------------------
1 | 清空结构内存
2 |
3 | ## 找Bug
4 | 这段代码来自于曾经的 Wolfenstein 3D项目 – 看看它有什么问题?
5 |
6 | ```cpp
7 | void CG_RegisterItemVisuals( int itemNum ) {
8 | ...
9 | itemInfo_t* itemInfo;
10 | ...
11 | memset( itemInfo, 0, sizeof( &itemInfo ) );
12 | ...
13 |
}
14 | ```
15 |
16 | ### 说明
17 | 这里的Bug出现在memset那一行。
18 | 代码的真实意图是清空iteminfo这块内存,但调用memset时,第三个参数传入的却是sizeof(&iteminfo),sizeof操作符返回的是指针的大小(32bit),而不是itemInfo_t这个结构体的大小。
19 | 正确的写法是:
20 | ```cpp
21 | memset(itemInfo, 0, sizeof(itemInfo_t));
22 | ```
23 | 或者
24 | ```cpp
25 | memset(itemInfo, 0, sizeof(*itemInfo));
26 | ```
27 |
28 | ---
29 | * [示例代码](../../source/bug403/source/main.cpp)
30 | ---
31 |
--------------------------------------------------------------------------------
/mds/bugs/bug542.md:
--------------------------------------------------------------------------------
1 | 指定长度的整形数
2 |
3 |
4 | ## 找Bug
5 | 下面这段代码会输出什么?为什么?
6 |
7 | ```cpp
8 | #include
9 |
10 | struct { int bit:1; } s;
11 |
12 | bool f()
13 | {
14 | if( s.bit > 0 ) return true;
15 | else return false;
16 | }
17 |
18 | int main()
19 | {
20 | s.bit = 1;
21 | if( f() ) printf( "the bit is ON\n" );
22 | else printf( "the bit is OFF\n" );
23 | return 0;
24 | }
25 | ```
26 |
27 | ### 说明
28 |
29 | 'int' 表示它是一个带符号的整数。对于带符号的整数,最左边的位将用作 +/- 符号。
30 | 如果在 1 位字段中存储 1: 最左边的位为 1,因此系统会将其值视为负数。
31 | 系统使用2的补码方法来处理负值。
32 |
33 | 因此,存储的数据为1。1的2的补码也为1(负数),此时这个int的值就是-1。f()的返回值也就是false。
34 |
35 | ---
36 | * [示例代码](../../source/bug542/source/main.cpp)
37 | ---
38 |
--------------------------------------------------------------------------------
/mds/bugs/bug602.md:
--------------------------------------------------------------------------------
1 | 注释使用
2 |
3 |
4 | ## 找Bug
5 |
6 | ```cpp
7 | #include
8 |
9 | int quotient(int *q, int *p)
10 | {
11 | if(*p) return *q/*p /* compute ratio */ ;
12 | else return *q;
13 | }
14 |
15 | int main()
16 | {
17 | int n = 20, m = 4;
18 | int q = quotient( &n, &m );
19 | printf( "%d/%d == %d\n", n, m, q );
20 | return 0;
21 | }
22 | ```
23 |
24 | ### 说明
25 | 结果是20,为什么?
26 | 这种注释在使用时要注意。
27 |
28 | ---
29 | * [示例代码](../../source/bug602/source/main.cpp)
30 | ---
31 |
--------------------------------------------------------------------------------
/mds/bugs/bug604.md:
--------------------------------------------------------------------------------
1 | 宏的使用
2 |
3 |
4 | ## 找Bug
5 |
6 | ```cpp
7 | //Project - Macro
8 | #include
9 | using namespace std;
10 |
11 | #define SQUARE(x) x*x
12 |
13 | int main() {
14 | cout << SQUARE(3) << endl; //3的平方,预期输出为9
15 | cout << SQUARE(3+2) << endl; //3+2的平方,预期输出为5的平方,即25
16 | return 0;
17 | }
18 | ```
19 |
20 | ### 说明
21 | SQUARE(3+2)的结果是11,为什么?
22 |
23 | 执行结果不符预期的原因与预处理器的工作原理有关,
24 | 宏定义SQUARE(x)是在预处理阶段由预处理器展开的,而展开的方式就是简单的文本替换。
25 | 对于预处理器而言,SQUARE(3+2)中的x即为“3+2”,按定义展开后是这样的:
26 |
27 | ```cpp
28 | 3+2*3+2
29 | ```
30 |
31 | ---
32 | * [示例代码](../../source/bug604/source/main.cpp)
33 | ---
34 |
--------------------------------------------------------------------------------
/source/Debug/gltop_bug2.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gonglei007/cpp-bugs-killer/190da7cfb42d332bc9a3c25729923ef2517a7e77/source/Debug/gltop_bug2.pdb
--------------------------------------------------------------------------------
/source/bug101/source/main.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 |
5 | class mat3_t{
6 | public:
7 | float mat[3][3];
8 | mat3_t( float src[3][3] );
9 | void print();
10 | };
11 |
12 | mat3_t::mat3_t( float src[3][3] )
13 | {
14 | memcpy( this->mat, src, sizeof( src ) );
15 | }
16 |
17 | void mat3_t::print()
18 | {
19 | for(int i=0; i<3; ++i){
20 | for(int j=0; j<3; ++j){
21 | std::cout << this->mat[i][j] << " ";
22 | }
23 | std::cout << std::endl;
24 | }
25 | }
26 |
27 | int main()
28 | {
29 | std::cout << "Output matrix:" << std::endl;
30 |
31 | float mat3Data[3][3] = {{0.0f, 0.0f, 0.0f}, {0.0f, 0.0f, 0.0f}, {1.0f, 1.0f, 1.0f}};
32 |
33 | mat3_t mat3(mat3Data);
34 | mat3.print();
35 |
36 | return 0;
37 | }
--------------------------------------------------------------------------------
/source/bug102/source/main.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 |
4 | /**
5 | * 检查投票通过率是否超过2/3。
6 | */
7 | bool CheckVotePassed(int votes, int total)
8 | {
9 | const int votePassNumber = 2;
10 | const int voteTotalNum = 3;
11 | return votes/total > votePassNumber/voteTotalNum;
12 | }
13 |
14 | int main()
15 | {
16 | cout << "投票是否通过:" << CheckVotePassed(40, 50) << endl;
17 | return 0;
18 | }
19 |
--------------------------------------------------------------------------------
/source/bug1536/config/xcode/bug1536.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 46;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | 67897E231510E137007F7200 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 67897E221510E137007F7200 /* main.cpp */; };
11 | 67897E251510E137007F7200 /* bug1536.1 in CopyFiles */ = {isa = PBXBuildFile; fileRef = 67897E241510E137007F7200 /* bug1536.1 */; };
12 | /* End PBXBuildFile section */
13 |
14 | /* Begin PBXCopyFilesBuildPhase section */
15 | 67897E1C1510E137007F7200 /* CopyFiles */ = {
16 | isa = PBXCopyFilesBuildPhase;
17 | buildActionMask = 2147483647;
18 | dstPath = /usr/share/man/man1/;
19 | dstSubfolderSpec = 0;
20 | files = (
21 | 67897E251510E137007F7200 /* bug1536.1 in CopyFiles */,
22 | );
23 | runOnlyForDeploymentPostprocessing = 1;
24 | };
25 | /* End PBXCopyFilesBuildPhase section */
26 |
27 | /* Begin PBXFileReference section */
28 | 67897E1E1510E137007F7200 /* bug1536 */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = bug1536; sourceTree = BUILT_PRODUCTS_DIR; };
29 | 67897E221510E137007F7200 /* main.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = ""; };
30 | 67897E241510E137007F7200 /* bug1536.1 */ = {isa = PBXFileReference; lastKnownFileType = text.man; path = bug1536.1; sourceTree = ""; };
31 | /* End PBXFileReference section */
32 |
33 | /* Begin PBXFrameworksBuildPhase section */
34 | 67897E1B1510E137007F7200 /* Frameworks */ = {
35 | isa = PBXFrameworksBuildPhase;
36 | buildActionMask = 2147483647;
37 | files = (
38 | );
39 | runOnlyForDeploymentPostprocessing = 0;
40 | };
41 | /* End PBXFrameworksBuildPhase section */
42 |
43 | /* Begin PBXGroup section */
44 | 67897E131510E137007F7200 = {
45 | isa = PBXGroup;
46 | children = (
47 | 67897E211510E137007F7200 /* bug1536 */,
48 | 67897E1F1510E137007F7200 /* Products */,
49 | );
50 | sourceTree = "";
51 | };
52 | 67897E1F1510E137007F7200 /* Products */ = {
53 | isa = PBXGroup;
54 | children = (
55 | 67897E1E1510E137007F7200 /* bug1536 */,
56 | );
57 | name = Products;
58 | sourceTree = "";
59 | };
60 | 67897E211510E137007F7200 /* bug1536 */ = {
61 | isa = PBXGroup;
62 | children = (
63 | 67897E221510E137007F7200 /* main.cpp */,
64 | 67897E241510E137007F7200 /* bug1536.1 */,
65 | );
66 | path = bug1536;
67 | sourceTree = "";
68 | };
69 | /* End PBXGroup section */
70 |
71 | /* Begin PBXNativeTarget section */
72 | 67897E1D1510E137007F7200 /* bug1536 */ = {
73 | isa = PBXNativeTarget;
74 | buildConfigurationList = 67897E281510E137007F7200 /* Build configuration list for PBXNativeTarget "bug1536" */;
75 | buildPhases = (
76 | 67897E1A1510E137007F7200 /* Sources */,
77 | 67897E1B1510E137007F7200 /* Frameworks */,
78 | 67897E1C1510E137007F7200 /* CopyFiles */,
79 | );
80 | buildRules = (
81 | );
82 | dependencies = (
83 | );
84 | name = bug1536;
85 | productName = bug1536;
86 | productReference = 67897E1E1510E137007F7200 /* bug1536 */;
87 | productType = "com.apple.product-type.tool";
88 | };
89 | /* End PBXNativeTarget section */
90 |
91 | /* Begin PBXProject section */
92 | 67897E151510E137007F7200 /* Project object */ = {
93 | isa = PBXProject;
94 | attributes = {
95 | LastUpgradeCheck = 0420;
96 | };
97 | buildConfigurationList = 67897E181510E137007F7200 /* Build configuration list for PBXProject "bug1536" */;
98 | compatibilityVersion = "Xcode 3.2";
99 | developmentRegion = English;
100 | hasScannedForEncodings = 0;
101 | knownRegions = (
102 | en,
103 | );
104 | mainGroup = 67897E131510E137007F7200;
105 | productRefGroup = 67897E1F1510E137007F7200 /* Products */;
106 | projectDirPath = "";
107 | projectRoot = "";
108 | targets = (
109 | 67897E1D1510E137007F7200 /* bug1536 */,
110 | );
111 | };
112 | /* End PBXProject section */
113 |
114 | /* Begin PBXSourcesBuildPhase section */
115 | 67897E1A1510E137007F7200 /* Sources */ = {
116 | isa = PBXSourcesBuildPhase;
117 | buildActionMask = 2147483647;
118 | files = (
119 | 67897E231510E137007F7200 /* main.cpp in Sources */,
120 | );
121 | runOnlyForDeploymentPostprocessing = 0;
122 | };
123 | /* End PBXSourcesBuildPhase section */
124 |
125 | /* Begin XCBuildConfiguration section */
126 | 67897E261510E137007F7200 /* Debug */ = {
127 | isa = XCBuildConfiguration;
128 | buildSettings = {
129 | ALWAYS_SEARCH_USER_PATHS = NO;
130 | ARCHS = "$(ARCHS_STANDARD_64_BIT)";
131 | COPY_PHASE_STRIP = NO;
132 | GCC_C_LANGUAGE_STANDARD = gnu99;
133 | GCC_DYNAMIC_NO_PIC = NO;
134 | GCC_ENABLE_OBJC_EXCEPTIONS = YES;
135 | GCC_OPTIMIZATION_LEVEL = 0;
136 | GCC_PREPROCESSOR_DEFINITIONS = (
137 | "DEBUG=1",
138 | "$(inherited)",
139 | );
140 | GCC_SYMBOLS_PRIVATE_EXTERN = NO;
141 | GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
142 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
143 | GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
144 | GCC_WARN_ABOUT_RETURN_TYPE = YES;
145 | GCC_WARN_UNUSED_VARIABLE = YES;
146 | MACOSX_DEPLOYMENT_TARGET = 10.7;
147 | ONLY_ACTIVE_ARCH = YES;
148 | SDKROOT = macosx;
149 | };
150 | name = Debug;
151 | };
152 | 67897E271510E137007F7200 /* Release */ = {
153 | isa = XCBuildConfiguration;
154 | buildSettings = {
155 | ALWAYS_SEARCH_USER_PATHS = NO;
156 | ARCHS = "$(ARCHS_STANDARD_64_BIT)";
157 | COPY_PHASE_STRIP = YES;
158 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
159 | GCC_C_LANGUAGE_STANDARD = gnu99;
160 | GCC_ENABLE_OBJC_EXCEPTIONS = YES;
161 | GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
162 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
163 | GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
164 | GCC_WARN_ABOUT_RETURN_TYPE = YES;
165 | GCC_WARN_UNUSED_VARIABLE = YES;
166 | MACOSX_DEPLOYMENT_TARGET = 10.7;
167 | SDKROOT = macosx;
168 | };
169 | name = Release;
170 | };
171 | 67897E291510E137007F7200 /* Debug */ = {
172 | isa = XCBuildConfiguration;
173 | buildSettings = {
174 | PRODUCT_NAME = "$(TARGET_NAME)";
175 | };
176 | name = Debug;
177 | };
178 | 67897E2A1510E137007F7200 /* Release */ = {
179 | isa = XCBuildConfiguration;
180 | buildSettings = {
181 | PRODUCT_NAME = "$(TARGET_NAME)";
182 | };
183 | name = Release;
184 | };
185 | /* End XCBuildConfiguration section */
186 |
187 | /* Begin XCConfigurationList section */
188 | 67897E181510E137007F7200 /* Build configuration list for PBXProject "bug1536" */ = {
189 | isa = XCConfigurationList;
190 | buildConfigurations = (
191 | 67897E261510E137007F7200 /* Debug */,
192 | 67897E271510E137007F7200 /* Release */,
193 | );
194 | defaultConfigurationIsVisible = 0;
195 | defaultConfigurationName = Release;
196 | };
197 | 67897E281510E137007F7200 /* Build configuration list for PBXNativeTarget "bug1536" */ = {
198 | isa = XCConfigurationList;
199 | buildConfigurations = (
200 | 67897E291510E137007F7200 /* Debug */,
201 | 67897E2A1510E137007F7200 /* Release */,
202 | );
203 | defaultConfigurationIsVisible = 0;
204 | };
205 | /* End XCConfigurationList section */
206 | };
207 | rootObject = 67897E151510E137007F7200 /* Project object */;
208 | }
209 |
--------------------------------------------------------------------------------
/source/bug1536/source/bug1536.1:
--------------------------------------------------------------------------------
1 | .\"Modified from man(1) of FreeBSD, the NetBSD mdoc.template, and mdoc.samples.
2 | .\"See Also:
3 | .\"man mdoc.samples for a complete listing of options
4 | .\"man mdoc for the short list of editing options
5 | .\"/usr/share/misc/mdoc.template
6 | .Dd 12-3-14 \" DATE
7 | .Dt bug1536 1 \" Program name and manual section number
8 | .Os Darwin
9 | .Sh NAME \" Section Header - required - don't modify
10 | .Nm bug1536,
11 | .\" The following lines are read in generating the apropos(man -k) database. Use only key
12 | .\" words here as the database is built based on the words here and in the .ND line.
13 | .Nm Other_name_for_same_program(),
14 | .Nm Yet another name for the same program.
15 | .\" Use .Nm macro to designate other names for the documented program.
16 | .Nd This line parsed for whatis database.
17 | .Sh SYNOPSIS \" Section Header - required - don't modify
18 | .Nm
19 | .Op Fl abcd \" [-abcd]
20 | .Op Fl a Ar path \" [-a path]
21 | .Op Ar file \" [file]
22 | .Op Ar \" [file ...]
23 | .Ar arg0 \" Underlined argument - use .Ar anywhere to underline
24 | arg2 ... \" Arguments
25 | .Sh DESCRIPTION \" Section Header - required - don't modify
26 | Use the .Nm macro to refer to your program throughout the man page like such:
27 | .Nm
28 | Underlining is accomplished with the .Ar macro like this:
29 | .Ar underlined text .
30 | .Pp \" Inserts a space
31 | A list of items with descriptions:
32 | .Bl -tag -width -indent \" Begins a tagged list
33 | .It item a \" Each item preceded by .It macro
34 | Description of item a
35 | .It item b
36 | Description of item b
37 | .El \" Ends the list
38 | .Pp
39 | A list of flags and their descriptions:
40 | .Bl -tag -width -indent \" Differs from above in tag removed
41 | .It Fl a \"-a flag as a list item
42 | Description of -a flag
43 | .It Fl b
44 | Description of -b flag
45 | .El \" Ends the list
46 | .Pp
47 | .\" .Sh ENVIRONMENT \" May not be needed
48 | .\" .Bl -tag -width "ENV_VAR_1" -indent \" ENV_VAR_1 is width of the string ENV_VAR_1
49 | .\" .It Ev ENV_VAR_1
50 | .\" Description of ENV_VAR_1
51 | .\" .It Ev ENV_VAR_2
52 | .\" Description of ENV_VAR_2
53 | .\" .El
54 | .Sh FILES \" File used or created by the topic of the man page
55 | .Bl -tag -width "/Users/joeuser/Library/really_long_file_name" -compact
56 | .It Pa /usr/share/file_name
57 | FILE_1 description
58 | .It Pa /Users/joeuser/Library/really_long_file_name
59 | FILE_2 description
60 | .El \" Ends the list
61 | .\" .Sh DIAGNOSTICS \" May not be needed
62 | .\" .Bl -diag
63 | .\" .It Diagnostic Tag
64 | .\" Diagnostic informtion here.
65 | .\" .It Diagnostic Tag
66 | .\" Diagnostic informtion here.
67 | .\" .El
68 | .Sh SEE ALSO
69 | .\" List links in ascending order by section, alphabetically within a section.
70 | .\" Please do not reference files that do not exist without filing a bug report
71 | .Xr a 1 ,
72 | .Xr b 1 ,
73 | .Xr c 1 ,
74 | .Xr a 2 ,
75 | .Xr b 2 ,
76 | .Xr a 3 ,
77 | .Xr b 3
78 | .\" .Sh BUGS \" Document known, unremedied bugs
79 | .\" .Sh HISTORY \" Document history if command behaves in a unique manner
--------------------------------------------------------------------------------
/source/bug1536/source/main.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // main.cpp
3 | // bug1536
4 | //
5 | // Created by Gong Lei on 12-3-14.
6 | // Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
7 | //
8 |
9 | #include
10 |
11 | class A
12 | {
13 | int count;
14 | public:
15 | A() :count(0) {}
16 | void bump() { count++; }
17 | int &usage() { return count; }
18 | };
19 | void report( int &n ) { n *= 2; }
20 | int main()
21 | {
22 | A a;
23 | a.bump();
24 | a.bump();
25 | report( a.usage() );
26 | printf( "%d\n", a.usage() );
27 | return 0;
28 | }
--------------------------------------------------------------------------------
/source/bug201/source/main.cpp:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | typedef const char* LPCSTR;
4 |
5 | /**
6 | * 检查一个字符串是否是空字符串。
7 | */
8 | bool CheckEmptyPassword(LPCSTR m_szPassword)
9 | {
10 | if (m_szPassword != NULL)
11 | {
12 | return true;
13 | }
14 | if (m_szPassword != '\0')
15 | {
16 | return true;
17 | }
18 | return false;
19 | }
20 |
21 | //const char* ClientResponse(LPCSTR ServerChallenge)
22 | //{
23 | // m_szPassword = "";
24 | //// ...
25 | // if (m_szPassword != NULL)
26 | // {
27 | //// ...
28 | // if (m_szPassword != '\0')
29 | // {
30 | //// ...
31 | // std::cout << "密码 " << m_szPassword << " 合法吗?" << std::endl;
32 | // }
33 | // }
34 | // return "";
35 | //}
36 |
37 |
38 | int main()
39 | {
40 | std::cout << CheckEmptyPassword("password") << std::endl;
41 | std::cout << CheckEmptyPassword("") << std::endl;
42 | return 0;
43 | }
--------------------------------------------------------------------------------
/source/bug401/source/main.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | using namespace std;
4 |
5 | typedef struct bot_state_s
6 | {
7 | // ...
8 | char teamleader[32] = "leader_name";
9 | bool dead = false;
10 | // ...
11 | }bot_state_t;
12 |
13 | /**
14 | *
15 | */
16 | void BotTeamAI( bot_state_t* bs ){
17 | // ...
18 | bs->teamleader[sizeof( bs->teamleader )] = '\0';
19 | // ...
20 | }
21 |
22 | int main()
23 | {
24 | bot_state_t bot_state;
25 | bot_state.dead = true;
26 | // strcpy(bot_state.teamleader, "leader_name");
27 |
28 | BotTeamAI(&bot_state);
29 | cout << "teamleader dead?-" << bot_state.dead << endl; // 看看bot_state.dead输出了什么?
30 | return 0;
31 | }
32 |
33 |
34 |
--------------------------------------------------------------------------------
/source/bug403/source/main.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | using namespace std;
4 |
5 | typedef struct itemInfo_s
6 | {
7 | // ...
8 | int data[5] = {1, 2, 3, 4, 5};
9 | // ...
10 | }itemInfo_t;
11 |
12 | itemInfo_t gItemInfo;
13 |
14 | void CG_RegisterItemVisuals( int itemNum ) {
15 | // ...
16 | itemInfo_t* itemInfo = &gItemInfo;
17 | // ...
18 | memset( itemInfo, 0, sizeof( &itemInfo ) );
19 | // ...
20 | }
21 |
22 | /**
23 | * 输出itemInfo的内容。
24 | */
25 | void printItemInfo(itemInfo_t itemInfo)
26 | {
27 | for(int i=0; i<5; ++i)
28 | {
29 | cout<
2 |
3 |
4 |
5 | Debug
6 | Win32
7 |
8 |
9 | Release
10 | Win32
11 |
12 |
13 |
14 |
15 |
16 |
17 | {BF742157-DE31-4352-8638-12C109F49F3A}
18 | Win32Proj
19 | bug542
20 |
21 |
22 |
23 | Application
24 | true
25 | Unicode
26 |
27 |
28 | Application
29 | false
30 | true
31 | Unicode
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 | true
45 |
46 |
47 | false
48 |
49 |
50 |
51 |
52 |
53 | Level3
54 | Disabled
55 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
56 |
57 |
58 | Console
59 | true
60 |
61 |
62 |
63 |
64 | Level3
65 |
66 |
67 | MaxSpeed
68 | true
69 | true
70 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
71 |
72 |
73 | Console
74 | true
75 | true
76 | true
77 |
78 |
79 |
80 |
81 |
82 |
--------------------------------------------------------------------------------
/source/bug542/config/vc2010/bug542.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {24ec776e-f929-4417-97d0-76735ccbdffd}
6 |
7 |
8 |
9 |
10 | source
11 |
12 |
13 |
--------------------------------------------------------------------------------
/source/bug542/config/xcode/bug542.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 46;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | 67897E0B1510DC11007F7200 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 67897E0A1510DC11007F7200 /* main.cpp */; };
11 | 67897E0D1510DC11007F7200 /* bug542.1 in CopyFiles */ = {isa = PBXBuildFile; fileRef = 67897E0C1510DC11007F7200 /* bug542.1 */; };
12 | /* End PBXBuildFile section */
13 |
14 | /* Begin PBXCopyFilesBuildPhase section */
15 | 67897E041510DC11007F7200 /* CopyFiles */ = {
16 | isa = PBXCopyFilesBuildPhase;
17 | buildActionMask = 2147483647;
18 | dstPath = /usr/share/man/man1/;
19 | dstSubfolderSpec = 0;
20 | files = (
21 | 67897E0D1510DC11007F7200 /* bug542.1 in CopyFiles */,
22 | );
23 | runOnlyForDeploymentPostprocessing = 1;
24 | };
25 | /* End PBXCopyFilesBuildPhase section */
26 |
27 | /* Begin PBXFileReference section */
28 | 67897E061510DC11007F7200 /* bug542 */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = bug542; sourceTree = BUILT_PRODUCTS_DIR; };
29 | 67897E0A1510DC11007F7200 /* main.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = ""; };
30 | 67897E0C1510DC11007F7200 /* bug542.1 */ = {isa = PBXFileReference; lastKnownFileType = text.man; path = bug542.1; sourceTree = ""; };
31 | /* End PBXFileReference section */
32 |
33 | /* Begin PBXFrameworksBuildPhase section */
34 | 67897E031510DC11007F7200 /* Frameworks */ = {
35 | isa = PBXFrameworksBuildPhase;
36 | buildActionMask = 2147483647;
37 | files = (
38 | );
39 | runOnlyForDeploymentPostprocessing = 0;
40 | };
41 | /* End PBXFrameworksBuildPhase section */
42 |
43 | /* Begin PBXGroup section */
44 | 67897DFB1510DC11007F7200 = {
45 | isa = PBXGroup;
46 | children = (
47 | 67897E091510DC11007F7200 /* bug542 */,
48 | 67897E071510DC11007F7200 /* Products */,
49 | );
50 | sourceTree = "";
51 | };
52 | 67897E071510DC11007F7200 /* Products */ = {
53 | isa = PBXGroup;
54 | children = (
55 | 67897E061510DC11007F7200 /* bug542 */,
56 | );
57 | name = Products;
58 | sourceTree = "";
59 | };
60 | 67897E091510DC11007F7200 /* bug542 */ = {
61 | isa = PBXGroup;
62 | children = (
63 | 67897E0A1510DC11007F7200 /* main.cpp */,
64 | 67897E0C1510DC11007F7200 /* bug542.1 */,
65 | );
66 | path = bug542;
67 | sourceTree = "";
68 | };
69 | /* End PBXGroup section */
70 |
71 | /* Begin PBXNativeTarget section */
72 | 67897E051510DC11007F7200 /* bug542 */ = {
73 | isa = PBXNativeTarget;
74 | buildConfigurationList = 67897E101510DC11007F7200 /* Build configuration list for PBXNativeTarget "bug542" */;
75 | buildPhases = (
76 | 67897E021510DC11007F7200 /* Sources */,
77 | 67897E031510DC11007F7200 /* Frameworks */,
78 | 67897E041510DC11007F7200 /* CopyFiles */,
79 | );
80 | buildRules = (
81 | );
82 | dependencies = (
83 | );
84 | name = bug542;
85 | productName = bug542;
86 | productReference = 67897E061510DC11007F7200 /* bug542 */;
87 | productType = "com.apple.product-type.tool";
88 | };
89 | /* End PBXNativeTarget section */
90 |
91 | /* Begin PBXProject section */
92 | 67897DFD1510DC11007F7200 /* Project object */ = {
93 | isa = PBXProject;
94 | attributes = {
95 | LastUpgradeCheck = 0420;
96 | };
97 | buildConfigurationList = 67897E001510DC11007F7200 /* Build configuration list for PBXProject "bug542" */;
98 | compatibilityVersion = "Xcode 3.2";
99 | developmentRegion = English;
100 | hasScannedForEncodings = 0;
101 | knownRegions = (
102 | en,
103 | );
104 | mainGroup = 67897DFB1510DC11007F7200;
105 | productRefGroup = 67897E071510DC11007F7200 /* Products */;
106 | projectDirPath = "";
107 | projectRoot = "";
108 | targets = (
109 | 67897E051510DC11007F7200 /* bug542 */,
110 | );
111 | };
112 | /* End PBXProject section */
113 |
114 | /* Begin PBXSourcesBuildPhase section */
115 | 67897E021510DC11007F7200 /* Sources */ = {
116 | isa = PBXSourcesBuildPhase;
117 | buildActionMask = 2147483647;
118 | files = (
119 | 67897E0B1510DC11007F7200 /* main.cpp in Sources */,
120 | );
121 | runOnlyForDeploymentPostprocessing = 0;
122 | };
123 | /* End PBXSourcesBuildPhase section */
124 |
125 | /* Begin XCBuildConfiguration section */
126 | 67897E0E1510DC11007F7200 /* Debug */ = {
127 | isa = XCBuildConfiguration;
128 | buildSettings = {
129 | ALWAYS_SEARCH_USER_PATHS = NO;
130 | ARCHS = "$(ARCHS_STANDARD_64_BIT)";
131 | COPY_PHASE_STRIP = NO;
132 | GCC_C_LANGUAGE_STANDARD = gnu99;
133 | GCC_DYNAMIC_NO_PIC = NO;
134 | GCC_ENABLE_OBJC_EXCEPTIONS = YES;
135 | GCC_OPTIMIZATION_LEVEL = 0;
136 | GCC_PREPROCESSOR_DEFINITIONS = (
137 | "DEBUG=1",
138 | "$(inherited)",
139 | );
140 | GCC_SYMBOLS_PRIVATE_EXTERN = NO;
141 | GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
142 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
143 | GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
144 | GCC_WARN_ABOUT_RETURN_TYPE = YES;
145 | GCC_WARN_UNUSED_VARIABLE = YES;
146 | MACOSX_DEPLOYMENT_TARGET = 10.7;
147 | ONLY_ACTIVE_ARCH = YES;
148 | SDKROOT = macosx;
149 | };
150 | name = Debug;
151 | };
152 | 67897E0F1510DC11007F7200 /* Release */ = {
153 | isa = XCBuildConfiguration;
154 | buildSettings = {
155 | ALWAYS_SEARCH_USER_PATHS = NO;
156 | ARCHS = "$(ARCHS_STANDARD_64_BIT)";
157 | COPY_PHASE_STRIP = YES;
158 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
159 | GCC_C_LANGUAGE_STANDARD = gnu99;
160 | GCC_ENABLE_OBJC_EXCEPTIONS = YES;
161 | GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
162 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
163 | GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
164 | GCC_WARN_ABOUT_RETURN_TYPE = YES;
165 | GCC_WARN_UNUSED_VARIABLE = YES;
166 | MACOSX_DEPLOYMENT_TARGET = 10.7;
167 | SDKROOT = macosx;
168 | };
169 | name = Release;
170 | };
171 | 67897E111510DC11007F7200 /* Debug */ = {
172 | isa = XCBuildConfiguration;
173 | buildSettings = {
174 | PRODUCT_NAME = "$(TARGET_NAME)";
175 | };
176 | name = Debug;
177 | };
178 | 67897E121510DC11007F7200 /* Release */ = {
179 | isa = XCBuildConfiguration;
180 | buildSettings = {
181 | PRODUCT_NAME = "$(TARGET_NAME)";
182 | };
183 | name = Release;
184 | };
185 | /* End XCBuildConfiguration section */
186 |
187 | /* Begin XCConfigurationList section */
188 | 67897E001510DC11007F7200 /* Build configuration list for PBXProject "bug542" */ = {
189 | isa = XCConfigurationList;
190 | buildConfigurations = (
191 | 67897E0E1510DC11007F7200 /* Debug */,
192 | 67897E0F1510DC11007F7200 /* Release */,
193 | );
194 | defaultConfigurationIsVisible = 0;
195 | defaultConfigurationName = Release;
196 | };
197 | 67897E101510DC11007F7200 /* Build configuration list for PBXNativeTarget "bug542" */ = {
198 | isa = XCConfigurationList;
199 | buildConfigurations = (
200 | 67897E111510DC11007F7200 /* Debug */,
201 | 67897E121510DC11007F7200 /* Release */,
202 | );
203 | defaultConfigurationIsVisible = 0;
204 | };
205 | /* End XCConfigurationList section */
206 | };
207 | rootObject = 67897DFD1510DC11007F7200 /* Project object */;
208 | }
209 |
--------------------------------------------------------------------------------
/source/bug542/source/bug542.1:
--------------------------------------------------------------------------------
1 | .\"Modified from man(1) of FreeBSD, the NetBSD mdoc.template, and mdoc.samples.
2 | .\"See Also:
3 | .\"man mdoc.samples for a complete listing of options
4 | .\"man mdoc for the short list of editing options
5 | .\"/usr/share/misc/mdoc.template
6 | .Dd 12-3-14 \" DATE
7 | .Dt bug542 1 \" Program name and manual section number
8 | .Os Darwin
9 | .Sh NAME \" Section Header - required - don't modify
10 | .Nm bug542,
11 | .\" The following lines are read in generating the apropos(man -k) database. Use only key
12 | .\" words here as the database is built based on the words here and in the .ND line.
13 | .Nm Other_name_for_same_program(),
14 | .Nm Yet another name for the same program.
15 | .\" Use .Nm macro to designate other names for the documented program.
16 | .Nd This line parsed for whatis database.
17 | .Sh SYNOPSIS \" Section Header - required - don't modify
18 | .Nm
19 | .Op Fl abcd \" [-abcd]
20 | .Op Fl a Ar path \" [-a path]
21 | .Op Ar file \" [file]
22 | .Op Ar \" [file ...]
23 | .Ar arg0 \" Underlined argument - use .Ar anywhere to underline
24 | arg2 ... \" Arguments
25 | .Sh DESCRIPTION \" Section Header - required - don't modify
26 | Use the .Nm macro to refer to your program throughout the man page like such:
27 | .Nm
28 | Underlining is accomplished with the .Ar macro like this:
29 | .Ar underlined text .
30 | .Pp \" Inserts a space
31 | A list of items with descriptions:
32 | .Bl -tag -width -indent \" Begins a tagged list
33 | .It item a \" Each item preceded by .It macro
34 | Description of item a
35 | .It item b
36 | Description of item b
37 | .El \" Ends the list
38 | .Pp
39 | A list of flags and their descriptions:
40 | .Bl -tag -width -indent \" Differs from above in tag removed
41 | .It Fl a \"-a flag as a list item
42 | Description of -a flag
43 | .It Fl b
44 | Description of -b flag
45 | .El \" Ends the list
46 | .Pp
47 | .\" .Sh ENVIRONMENT \" May not be needed
48 | .\" .Bl -tag -width "ENV_VAR_1" -indent \" ENV_VAR_1 is width of the string ENV_VAR_1
49 | .\" .It Ev ENV_VAR_1
50 | .\" Description of ENV_VAR_1
51 | .\" .It Ev ENV_VAR_2
52 | .\" Description of ENV_VAR_2
53 | .\" .El
54 | .Sh FILES \" File used or created by the topic of the man page
55 | .Bl -tag -width "/Users/joeuser/Library/really_long_file_name" -compact
56 | .It Pa /usr/share/file_name
57 | FILE_1 description
58 | .It Pa /Users/joeuser/Library/really_long_file_name
59 | FILE_2 description
60 | .El \" Ends the list
61 | .\" .Sh DIAGNOSTICS \" May not be needed
62 | .\" .Bl -diag
63 | .\" .It Diagnostic Tag
64 | .\" Diagnostic informtion here.
65 | .\" .It Diagnostic Tag
66 | .\" Diagnostic informtion here.
67 | .\" .El
68 | .Sh SEE ALSO
69 | .\" List links in ascending order by section, alphabetically within a section.
70 | .\" Please do not reference files that do not exist without filing a bug report
71 | .Xr a 1 ,
72 | .Xr b 1 ,
73 | .Xr c 1 ,
74 | .Xr a 2 ,
75 | .Xr b 2 ,
76 | .Xr a 3 ,
77 | .Xr b 3
78 | .\" .Sh BUGS \" Document known, unremedied bugs
79 | .\" .Sh HISTORY \" Document history if command behaves in a unique manner
--------------------------------------------------------------------------------
/source/bug542/source/main.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // main.cpp
3 | // bug542
4 | //
5 | // Created by Gong Lei on 12-3-14.
6 | // Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
7 | //
8 |
9 | #include
10 |
11 | struct { int bit:1; } s;
12 |
13 | bool f()
14 | {
15 | if( s.bit > 0 ) return true;
16 | else return false;
17 | }
18 |
19 | int main()
20 | {
21 | s.bit = 1;
22 | if( f() ) printf( "the bit is ON\n" );
23 | else printf( "the bit is OFF\n" );
24 | return 0;
25 | }
--------------------------------------------------------------------------------
/source/bug601/source/main.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | using namespace std;
4 |
5 | class Complex
6 | {
7 | public:
8 | double real, imag;
9 | Complex(double inReal, double inImaq)
10 | {
11 | real = inReal;
12 | imag = inImaq;
13 | }
14 |
15 | Complex& operator+( Complex& a, Complex& b);
16 | void Output();
17 | };
18 |
19 | Complex& Complex::operator+( Complex& a, Complex& b)
20 | {
21 | Complex *p = new Complex;
22 | p->real = a.real + b.real;
23 | p->imag = a.imag + b.imag;
24 | return *p;
25 | }
26 |
27 | void Complex::Output()
28 | {
29 | cout << "real=" << this.real <
2 |
3 |
4 |
5 | Debug
6 | Win32
7 |
8 |
9 | Release
10 | Win32
11 |
12 |
13 |
14 | {32A2CA6E-ADAF-4EBB-9679-497620904799}
15 | Win32Proj
16 | bug602
17 |
18 |
19 |
20 | Application
21 | true
22 | Unicode
23 |
24 |
25 | Application
26 | false
27 | true
28 | Unicode
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 | true
42 |
43 |
44 | false
45 |
46 |
47 |
48 |
49 |
50 | Level3
51 | Disabled
52 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
53 |
54 |
55 | Console
56 | true
57 |
58 |
59 |
60 |
61 | Level3
62 |
63 |
64 | MaxSpeed
65 | true
66 | true
67 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
68 |
69 |
70 | Console
71 | true
72 | true
73 | true
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
--------------------------------------------------------------------------------
/source/bug602/config/vc2010/bug602.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {cc90ade2-eb94-46cc-855e-ccf42568726d}
6 |
7 |
8 |
9 |
10 | source
11 |
12 |
13 |
--------------------------------------------------------------------------------
/source/bug602/config/xcode/bug602.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 46;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | 67897E3B1510E4EA007F7200 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 67897E3A1510E4EA007F7200 /* main.cpp */; };
11 | 67897E3D1510E4EA007F7200 /* bug602.1 in CopyFiles */ = {isa = PBXBuildFile; fileRef = 67897E3C1510E4EA007F7200 /* bug602.1 */; };
12 | /* End PBXBuildFile section */
13 |
14 | /* Begin PBXCopyFilesBuildPhase section */
15 | 67897E341510E4EA007F7200 /* CopyFiles */ = {
16 | isa = PBXCopyFilesBuildPhase;
17 | buildActionMask = 2147483647;
18 | dstPath = /usr/share/man/man1/;
19 | dstSubfolderSpec = 0;
20 | files = (
21 | 67897E3D1510E4EA007F7200 /* bug602.1 in CopyFiles */,
22 | );
23 | runOnlyForDeploymentPostprocessing = 1;
24 | };
25 | /* End PBXCopyFilesBuildPhase section */
26 |
27 | /* Begin PBXFileReference section */
28 | 67897E361510E4EA007F7200 /* bug602 */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = bug602; sourceTree = BUILT_PRODUCTS_DIR; };
29 | 67897E3A1510E4EA007F7200 /* main.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = ""; };
30 | 67897E3C1510E4EA007F7200 /* bug602.1 */ = {isa = PBXFileReference; lastKnownFileType = text.man; path = bug602.1; sourceTree = ""; };
31 | /* End PBXFileReference section */
32 |
33 | /* Begin PBXFrameworksBuildPhase section */
34 | 67897E331510E4EA007F7200 /* Frameworks */ = {
35 | isa = PBXFrameworksBuildPhase;
36 | buildActionMask = 2147483647;
37 | files = (
38 | );
39 | runOnlyForDeploymentPostprocessing = 0;
40 | };
41 | /* End PBXFrameworksBuildPhase section */
42 |
43 | /* Begin PBXGroup section */
44 | 67897E2B1510E4EA007F7200 = {
45 | isa = PBXGroup;
46 | children = (
47 | 67897E391510E4EA007F7200 /* bug602 */,
48 | 67897E371510E4EA007F7200 /* Products */,
49 | );
50 | sourceTree = "";
51 | };
52 | 67897E371510E4EA007F7200 /* Products */ = {
53 | isa = PBXGroup;
54 | children = (
55 | 67897E361510E4EA007F7200 /* bug602 */,
56 | );
57 | name = Products;
58 | sourceTree = "";
59 | };
60 | 67897E391510E4EA007F7200 /* bug602 */ = {
61 | isa = PBXGroup;
62 | children = (
63 | 67897E3A1510E4EA007F7200 /* main.cpp */,
64 | 67897E3C1510E4EA007F7200 /* bug602.1 */,
65 | );
66 | path = bug602;
67 | sourceTree = "";
68 | };
69 | /* End PBXGroup section */
70 |
71 | /* Begin PBXNativeTarget section */
72 | 67897E351510E4EA007F7200 /* bug602 */ = {
73 | isa = PBXNativeTarget;
74 | buildConfigurationList = 67897E401510E4EA007F7200 /* Build configuration list for PBXNativeTarget "bug602" */;
75 | buildPhases = (
76 | 67897E321510E4EA007F7200 /* Sources */,
77 | 67897E331510E4EA007F7200 /* Frameworks */,
78 | 67897E341510E4EA007F7200 /* CopyFiles */,
79 | );
80 | buildRules = (
81 | );
82 | dependencies = (
83 | );
84 | name = bug602;
85 | productName = bug602;
86 | productReference = 67897E361510E4EA007F7200 /* bug602 */;
87 | productType = "com.apple.product-type.tool";
88 | };
89 | /* End PBXNativeTarget section */
90 |
91 | /* Begin PBXProject section */
92 | 67897E2D1510E4EA007F7200 /* Project object */ = {
93 | isa = PBXProject;
94 | attributes = {
95 | LastUpgradeCheck = 0420;
96 | };
97 | buildConfigurationList = 67897E301510E4EA007F7200 /* Build configuration list for PBXProject "bug602" */;
98 | compatibilityVersion = "Xcode 3.2";
99 | developmentRegion = English;
100 | hasScannedForEncodings = 0;
101 | knownRegions = (
102 | en,
103 | );
104 | mainGroup = 67897E2B1510E4EA007F7200;
105 | productRefGroup = 67897E371510E4EA007F7200 /* Products */;
106 | projectDirPath = "";
107 | projectRoot = "";
108 | targets = (
109 | 67897E351510E4EA007F7200 /* bug602 */,
110 | );
111 | };
112 | /* End PBXProject section */
113 |
114 | /* Begin PBXSourcesBuildPhase section */
115 | 67897E321510E4EA007F7200 /* Sources */ = {
116 | isa = PBXSourcesBuildPhase;
117 | buildActionMask = 2147483647;
118 | files = (
119 | 67897E3B1510E4EA007F7200 /* main.cpp in Sources */,
120 | );
121 | runOnlyForDeploymentPostprocessing = 0;
122 | };
123 | /* End PBXSourcesBuildPhase section */
124 |
125 | /* Begin XCBuildConfiguration section */
126 | 67897E3E1510E4EA007F7200 /* Debug */ = {
127 | isa = XCBuildConfiguration;
128 | buildSettings = {
129 | ALWAYS_SEARCH_USER_PATHS = NO;
130 | ARCHS = "$(ARCHS_STANDARD_64_BIT)";
131 | COPY_PHASE_STRIP = NO;
132 | GCC_C_LANGUAGE_STANDARD = gnu99;
133 | GCC_DYNAMIC_NO_PIC = NO;
134 | GCC_ENABLE_OBJC_EXCEPTIONS = YES;
135 | GCC_OPTIMIZATION_LEVEL = 0;
136 | GCC_PREPROCESSOR_DEFINITIONS = (
137 | "DEBUG=1",
138 | "$(inherited)",
139 | );
140 | GCC_SYMBOLS_PRIVATE_EXTERN = NO;
141 | GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
142 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
143 | GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
144 | GCC_WARN_ABOUT_RETURN_TYPE = YES;
145 | GCC_WARN_UNUSED_VARIABLE = YES;
146 | MACOSX_DEPLOYMENT_TARGET = 10.7;
147 | ONLY_ACTIVE_ARCH = YES;
148 | SDKROOT = macosx;
149 | };
150 | name = Debug;
151 | };
152 | 67897E3F1510E4EA007F7200 /* Release */ = {
153 | isa = XCBuildConfiguration;
154 | buildSettings = {
155 | ALWAYS_SEARCH_USER_PATHS = NO;
156 | ARCHS = "$(ARCHS_STANDARD_64_BIT)";
157 | COPY_PHASE_STRIP = YES;
158 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
159 | GCC_C_LANGUAGE_STANDARD = gnu99;
160 | GCC_ENABLE_OBJC_EXCEPTIONS = YES;
161 | GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
162 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
163 | GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
164 | GCC_WARN_ABOUT_RETURN_TYPE = YES;
165 | GCC_WARN_UNUSED_VARIABLE = YES;
166 | MACOSX_DEPLOYMENT_TARGET = 10.7;
167 | SDKROOT = macosx;
168 | };
169 | name = Release;
170 | };
171 | 67897E411510E4EA007F7200 /* Debug */ = {
172 | isa = XCBuildConfiguration;
173 | buildSettings = {
174 | PRODUCT_NAME = "$(TARGET_NAME)";
175 | };
176 | name = Debug;
177 | };
178 | 67897E421510E4EA007F7200 /* Release */ = {
179 | isa = XCBuildConfiguration;
180 | buildSettings = {
181 | PRODUCT_NAME = "$(TARGET_NAME)";
182 | };
183 | name = Release;
184 | };
185 | /* End XCBuildConfiguration section */
186 |
187 | /* Begin XCConfigurationList section */
188 | 67897E301510E4EA007F7200 /* Build configuration list for PBXProject "bug602" */ = {
189 | isa = XCConfigurationList;
190 | buildConfigurations = (
191 | 67897E3E1510E4EA007F7200 /* Debug */,
192 | 67897E3F1510E4EA007F7200 /* Release */,
193 | );
194 | defaultConfigurationIsVisible = 0;
195 | defaultConfigurationName = Release;
196 | };
197 | 67897E401510E4EA007F7200 /* Build configuration list for PBXNativeTarget "bug602" */ = {
198 | isa = XCConfigurationList;
199 | buildConfigurations = (
200 | 67897E411510E4EA007F7200 /* Debug */,
201 | 67897E421510E4EA007F7200 /* Release */,
202 | );
203 | defaultConfigurationIsVisible = 0;
204 | };
205 | /* End XCConfigurationList section */
206 | };
207 | rootObject = 67897E2D1510E4EA007F7200 /* Project object */;
208 | }
209 |
--------------------------------------------------------------------------------
/source/bug602/source/bug602.1:
--------------------------------------------------------------------------------
1 | .\"Modified from man(1) of FreeBSD, the NetBSD mdoc.template, and mdoc.samples.
2 | .\"See Also:
3 | .\"man mdoc.samples for a complete listing of options
4 | .\"man mdoc for the short list of editing options
5 | .\"/usr/share/misc/mdoc.template
6 | .Dd 12-3-14 \" DATE
7 | .Dt bug602 1 \" Program name and manual section number
8 | .Os Darwin
9 | .Sh NAME \" Section Header - required - don't modify
10 | .Nm bug602,
11 | .\" The following lines are read in generating the apropos(man -k) database. Use only key
12 | .\" words here as the database is built based on the words here and in the .ND line.
13 | .Nm Other_name_for_same_program(),
14 | .Nm Yet another name for the same program.
15 | .\" Use .Nm macro to designate other names for the documented program.
16 | .Nd This line parsed for whatis database.
17 | .Sh SYNOPSIS \" Section Header - required - don't modify
18 | .Nm
19 | .Op Fl abcd \" [-abcd]
20 | .Op Fl a Ar path \" [-a path]
21 | .Op Ar file \" [file]
22 | .Op Ar \" [file ...]
23 | .Ar arg0 \" Underlined argument - use .Ar anywhere to underline
24 | arg2 ... \" Arguments
25 | .Sh DESCRIPTION \" Section Header - required - don't modify
26 | Use the .Nm macro to refer to your program throughout the man page like such:
27 | .Nm
28 | Underlining is accomplished with the .Ar macro like this:
29 | .Ar underlined text .
30 | .Pp \" Inserts a space
31 | A list of items with descriptions:
32 | .Bl -tag -width -indent \" Begins a tagged list
33 | .It item a \" Each item preceded by .It macro
34 | Description of item a
35 | .It item b
36 | Description of item b
37 | .El \" Ends the list
38 | .Pp
39 | A list of flags and their descriptions:
40 | .Bl -tag -width -indent \" Differs from above in tag removed
41 | .It Fl a \"-a flag as a list item
42 | Description of -a flag
43 | .It Fl b
44 | Description of -b flag
45 | .El \" Ends the list
46 | .Pp
47 | .\" .Sh ENVIRONMENT \" May not be needed
48 | .\" .Bl -tag -width "ENV_VAR_1" -indent \" ENV_VAR_1 is width of the string ENV_VAR_1
49 | .\" .It Ev ENV_VAR_1
50 | .\" Description of ENV_VAR_1
51 | .\" .It Ev ENV_VAR_2
52 | .\" Description of ENV_VAR_2
53 | .\" .El
54 | .Sh FILES \" File used or created by the topic of the man page
55 | .Bl -tag -width "/Users/joeuser/Library/really_long_file_name" -compact
56 | .It Pa /usr/share/file_name
57 | FILE_1 description
58 | .It Pa /Users/joeuser/Library/really_long_file_name
59 | FILE_2 description
60 | .El \" Ends the list
61 | .\" .Sh DIAGNOSTICS \" May not be needed
62 | .\" .Bl -diag
63 | .\" .It Diagnostic Tag
64 | .\" Diagnostic informtion here.
65 | .\" .It Diagnostic Tag
66 | .\" Diagnostic informtion here.
67 | .\" .El
68 | .Sh SEE ALSO
69 | .\" List links in ascending order by section, alphabetically within a section.
70 | .\" Please do not reference files that do not exist without filing a bug report
71 | .Xr a 1 ,
72 | .Xr b 1 ,
73 | .Xr c 1 ,
74 | .Xr a 2 ,
75 | .Xr b 2 ,
76 | .Xr a 3 ,
77 | .Xr b 3
78 | .\" .Sh BUGS \" Document known, unremedied bugs
79 | .\" .Sh HISTORY \" Document history if command behaves in a unique manner
--------------------------------------------------------------------------------
/source/bug602/source/main.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // main.cpp
3 | // bug602
4 | //
5 | // Created by Gong Lei on 12-3-14.
6 | // Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
7 | //
8 |
9 | #include
10 |
11 | int quotient(int *q, int *p)
12 | {
13 | if(*p) return *q/*p /* compute ratio */ ;
14 | else return *q;
15 | }
16 |
17 | int main()
18 | {
19 | int n = 20, m = 4;
20 | int q = quotient( &n, &m );
21 | printf( "%d/%d == %d\n", n, m, q );
22 | return 0;
23 | }
24 |
--------------------------------------------------------------------------------
/source/bug603/config/xcode/bug603.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 46;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | 67897DF31510D941007F7200 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 67897DF21510D941007F7200 /* main.cpp */; };
11 | 67897DF51510D942007F7200 /* bug603.1 in CopyFiles */ = {isa = PBXBuildFile; fileRef = 67897DF41510D942007F7200 /* bug603.1 */; };
12 | /* End PBXBuildFile section */
13 |
14 | /* Begin PBXCopyFilesBuildPhase section */
15 | 67897DEC1510D941007F7200 /* CopyFiles */ = {
16 | isa = PBXCopyFilesBuildPhase;
17 | buildActionMask = 2147483647;
18 | dstPath = /usr/share/man/man1/;
19 | dstSubfolderSpec = 0;
20 | files = (
21 | 67897DF51510D942007F7200 /* bug603.1 in CopyFiles */,
22 | );
23 | runOnlyForDeploymentPostprocessing = 1;
24 | };
25 | /* End PBXCopyFilesBuildPhase section */
26 |
27 | /* Begin PBXFileReference section */
28 | 67897DEE1510D941007F7200 /* bug603 */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = bug603; sourceTree = BUILT_PRODUCTS_DIR; };
29 | 67897DF21510D941007F7200 /* main.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = ""; };
30 | 67897DF41510D942007F7200 /* bug603.1 */ = {isa = PBXFileReference; lastKnownFileType = text.man; path = bug603.1; sourceTree = ""; };
31 | /* End PBXFileReference section */
32 |
33 | /* Begin PBXFrameworksBuildPhase section */
34 | 67897DEB1510D941007F7200 /* Frameworks */ = {
35 | isa = PBXFrameworksBuildPhase;
36 | buildActionMask = 2147483647;
37 | files = (
38 | );
39 | runOnlyForDeploymentPostprocessing = 0;
40 | };
41 | /* End PBXFrameworksBuildPhase section */
42 |
43 | /* Begin PBXGroup section */
44 | 67897DE31510D941007F7200 = {
45 | isa = PBXGroup;
46 | children = (
47 | 67897DF11510D941007F7200 /* bug603 */,
48 | 67897DEF1510D941007F7200 /* Products */,
49 | );
50 | sourceTree = "";
51 | };
52 | 67897DEF1510D941007F7200 /* Products */ = {
53 | isa = PBXGroup;
54 | children = (
55 | 67897DEE1510D941007F7200 /* bug603 */,
56 | );
57 | name = Products;
58 | sourceTree = "";
59 | };
60 | 67897DF11510D941007F7200 /* bug603 */ = {
61 | isa = PBXGroup;
62 | children = (
63 | 67897DF21510D941007F7200 /* main.cpp */,
64 | 67897DF41510D942007F7200 /* bug603.1 */,
65 | );
66 | path = bug603;
67 | sourceTree = "";
68 | };
69 | /* End PBXGroup section */
70 |
71 | /* Begin PBXNativeTarget section */
72 | 67897DED1510D941007F7200 /* bug603 */ = {
73 | isa = PBXNativeTarget;
74 | buildConfigurationList = 67897DF81510D942007F7200 /* Build configuration list for PBXNativeTarget "bug603" */;
75 | buildPhases = (
76 | 67897DEA1510D941007F7200 /* Sources */,
77 | 67897DEB1510D941007F7200 /* Frameworks */,
78 | 67897DEC1510D941007F7200 /* CopyFiles */,
79 | );
80 | buildRules = (
81 | );
82 | dependencies = (
83 | );
84 | name = bug603;
85 | productName = bug603;
86 | productReference = 67897DEE1510D941007F7200 /* bug603 */;
87 | productType = "com.apple.product-type.tool";
88 | };
89 | /* End PBXNativeTarget section */
90 |
91 | /* Begin PBXProject section */
92 | 67897DE51510D941007F7200 /* Project object */ = {
93 | isa = PBXProject;
94 | attributes = {
95 | LastUpgradeCheck = 0420;
96 | };
97 | buildConfigurationList = 67897DE81510D941007F7200 /* Build configuration list for PBXProject "bug603" */;
98 | compatibilityVersion = "Xcode 3.2";
99 | developmentRegion = English;
100 | hasScannedForEncodings = 0;
101 | knownRegions = (
102 | en,
103 | );
104 | mainGroup = 67897DE31510D941007F7200;
105 | productRefGroup = 67897DEF1510D941007F7200 /* Products */;
106 | projectDirPath = "";
107 | projectRoot = "";
108 | targets = (
109 | 67897DED1510D941007F7200 /* bug603 */,
110 | );
111 | };
112 | /* End PBXProject section */
113 |
114 | /* Begin PBXSourcesBuildPhase section */
115 | 67897DEA1510D941007F7200 /* Sources */ = {
116 | isa = PBXSourcesBuildPhase;
117 | buildActionMask = 2147483647;
118 | files = (
119 | 67897DF31510D941007F7200 /* main.cpp in Sources */,
120 | );
121 | runOnlyForDeploymentPostprocessing = 0;
122 | };
123 | /* End PBXSourcesBuildPhase section */
124 |
125 | /* Begin XCBuildConfiguration section */
126 | 67897DF61510D942007F7200 /* Debug */ = {
127 | isa = XCBuildConfiguration;
128 | buildSettings = {
129 | ALWAYS_SEARCH_USER_PATHS = NO;
130 | ARCHS = "$(ARCHS_STANDARD_64_BIT)";
131 | COPY_PHASE_STRIP = NO;
132 | GCC_C_LANGUAGE_STANDARD = gnu99;
133 | GCC_DYNAMIC_NO_PIC = NO;
134 | GCC_ENABLE_OBJC_EXCEPTIONS = YES;
135 | GCC_OPTIMIZATION_LEVEL = 0;
136 | GCC_PREPROCESSOR_DEFINITIONS = (
137 | "DEBUG=1",
138 | "$(inherited)",
139 | );
140 | GCC_SYMBOLS_PRIVATE_EXTERN = NO;
141 | GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
142 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
143 | GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
144 | GCC_WARN_ABOUT_RETURN_TYPE = YES;
145 | GCC_WARN_UNUSED_VARIABLE = YES;
146 | MACOSX_DEPLOYMENT_TARGET = 10.7;
147 | ONLY_ACTIVE_ARCH = YES;
148 | SDKROOT = macosx;
149 | };
150 | name = Debug;
151 | };
152 | 67897DF71510D942007F7200 /* Release */ = {
153 | isa = XCBuildConfiguration;
154 | buildSettings = {
155 | ALWAYS_SEARCH_USER_PATHS = NO;
156 | ARCHS = "$(ARCHS_STANDARD_64_BIT)";
157 | COPY_PHASE_STRIP = YES;
158 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
159 | GCC_C_LANGUAGE_STANDARD = gnu99;
160 | GCC_ENABLE_OBJC_EXCEPTIONS = YES;
161 | GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
162 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
163 | GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
164 | GCC_WARN_ABOUT_RETURN_TYPE = YES;
165 | GCC_WARN_UNUSED_VARIABLE = YES;
166 | MACOSX_DEPLOYMENT_TARGET = 10.7;
167 | SDKROOT = macosx;
168 | };
169 | name = Release;
170 | };
171 | 67897DF91510D942007F7200 /* Debug */ = {
172 | isa = XCBuildConfiguration;
173 | buildSettings = {
174 | PRODUCT_NAME = "$(TARGET_NAME)";
175 | };
176 | name = Debug;
177 | };
178 | 67897DFA1510D942007F7200 /* Release */ = {
179 | isa = XCBuildConfiguration;
180 | buildSettings = {
181 | PRODUCT_NAME = "$(TARGET_NAME)";
182 | };
183 | name = Release;
184 | };
185 | /* End XCBuildConfiguration section */
186 |
187 | /* Begin XCConfigurationList section */
188 | 67897DE81510D941007F7200 /* Build configuration list for PBXProject "bug603" */ = {
189 | isa = XCConfigurationList;
190 | buildConfigurations = (
191 | 67897DF61510D942007F7200 /* Debug */,
192 | 67897DF71510D942007F7200 /* Release */,
193 | );
194 | defaultConfigurationIsVisible = 0;
195 | defaultConfigurationName = Release;
196 | };
197 | 67897DF81510D942007F7200 /* Build configuration list for PBXNativeTarget "bug603" */ = {
198 | isa = XCConfigurationList;
199 | buildConfigurations = (
200 | 67897DF91510D942007F7200 /* Debug */,
201 | 67897DFA1510D942007F7200 /* Release */,
202 | );
203 | defaultConfigurationIsVisible = 0;
204 | };
205 | /* End XCConfigurationList section */
206 | };
207 | rootObject = 67897DE51510D941007F7200 /* Project object */;
208 | }
209 |
--------------------------------------------------------------------------------
/source/bug603/source/bug603.1:
--------------------------------------------------------------------------------
1 | .\"Modified from man(1) of FreeBSD, the NetBSD mdoc.template, and mdoc.samples.
2 | .\"See Also:
3 | .\"man mdoc.samples for a complete listing of options
4 | .\"man mdoc for the short list of editing options
5 | .\"/usr/share/misc/mdoc.template
6 | .Dd 12-3-14 \" DATE
7 | .Dt bug603 1 \" Program name and manual section number
8 | .Os Darwin
9 | .Sh NAME \" Section Header - required - don't modify
10 | .Nm bug603,
11 | .\" The following lines are read in generating the apropos(man -k) database. Use only key
12 | .\" words here as the database is built based on the words here and in the .ND line.
13 | .Nm Other_name_for_same_program(),
14 | .Nm Yet another name for the same program.
15 | .\" Use .Nm macro to designate other names for the documented program.
16 | .Nd This line parsed for whatis database.
17 | .Sh SYNOPSIS \" Section Header - required - don't modify
18 | .Nm
19 | .Op Fl abcd \" [-abcd]
20 | .Op Fl a Ar path \" [-a path]
21 | .Op Ar file \" [file]
22 | .Op Ar \" [file ...]
23 | .Ar arg0 \" Underlined argument - use .Ar anywhere to underline
24 | arg2 ... \" Arguments
25 | .Sh DESCRIPTION \" Section Header - required - don't modify
26 | Use the .Nm macro to refer to your program throughout the man page like such:
27 | .Nm
28 | Underlining is accomplished with the .Ar macro like this:
29 | .Ar underlined text .
30 | .Pp \" Inserts a space
31 | A list of items with descriptions:
32 | .Bl -tag -width -indent \" Begins a tagged list
33 | .It item a \" Each item preceded by .It macro
34 | Description of item a
35 | .It item b
36 | Description of item b
37 | .El \" Ends the list
38 | .Pp
39 | A list of flags and their descriptions:
40 | .Bl -tag -width -indent \" Differs from above in tag removed
41 | .It Fl a \"-a flag as a list item
42 | Description of -a flag
43 | .It Fl b
44 | Description of -b flag
45 | .El \" Ends the list
46 | .Pp
47 | .\" .Sh ENVIRONMENT \" May not be needed
48 | .\" .Bl -tag -width "ENV_VAR_1" -indent \" ENV_VAR_1 is width of the string ENV_VAR_1
49 | .\" .It Ev ENV_VAR_1
50 | .\" Description of ENV_VAR_1
51 | .\" .It Ev ENV_VAR_2
52 | .\" Description of ENV_VAR_2
53 | .\" .El
54 | .Sh FILES \" File used or created by the topic of the man page
55 | .Bl -tag -width "/Users/joeuser/Library/really_long_file_name" -compact
56 | .It Pa /usr/share/file_name
57 | FILE_1 description
58 | .It Pa /Users/joeuser/Library/really_long_file_name
59 | FILE_2 description
60 | .El \" Ends the list
61 | .\" .Sh DIAGNOSTICS \" May not be needed
62 | .\" .Bl -diag
63 | .\" .It Diagnostic Tag
64 | .\" Diagnostic informtion here.
65 | .\" .It Diagnostic Tag
66 | .\" Diagnostic informtion here.
67 | .\" .El
68 | .Sh SEE ALSO
69 | .\" List links in ascending order by section, alphabetically within a section.
70 | .\" Please do not reference files that do not exist without filing a bug report
71 | .Xr a 1 ,
72 | .Xr b 1 ,
73 | .Xr c 1 ,
74 | .Xr a 2 ,
75 | .Xr b 2 ,
76 | .Xr a 3 ,
77 | .Xr b 3
78 | .\" .Sh BUGS \" Document known, unremedied bugs
79 | .\" .Sh HISTORY \" Document history if command behaves in a unique manner
--------------------------------------------------------------------------------
/source/bug603/source/main.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // main.cpp
3 | // bug603
4 | //
5 | // Created by Gong Lei on 12-3-14.
6 | // Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
7 | //
8 |
9 | #include
10 | #include
11 |
12 | //TODO: GL - not finished
13 | void string_copy( const char *, char * );
14 |
15 | int main (int argc, const char * argv[])
16 | {
17 | char buf[12];
18 | string_copy( buf, "hello world" );
19 | printf( "%s\n", buf );
20 | return 0;
21 | }
22 |
23 |
--------------------------------------------------------------------------------
/source/bug604/source/main.cpp:
--------------------------------------------------------------------------------
1 | //Project - Macro
2 | #include
3 | using namespace std;
4 |
5 | #define SQUARE(x) x*x
6 |
7 | int main() {
8 | cout << SQUARE(3) << endl; //3的平方,预期输出为9
9 | cout << SQUARE(3+2) << endl; //3+2的平方,预期输出为5的平方,即25
10 | return 0;
11 | }
12 |
--------------------------------------------------------------------------------
/source/cpp_samples.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 11.00
3 | # Visual Studio 2010
4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gltop_bug2", "gltop_bug2\config\vc2010\gltop_bug2.vcxproj", "{F5007FD4-B67B-4A82-8035-7FE492EA34A8}"
5 | EndProject
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bug542", "bug542\config\vc2010\bug542.vcxproj", "{BF742157-DE31-4352-8638-12C109F49F3A}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Win32 = Debug|Win32
11 | Release|Win32 = Release|Win32
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {F5007FD4-B67B-4A82-8035-7FE492EA34A8}.Debug|Win32.ActiveCfg = Debug|Win32
15 | {F5007FD4-B67B-4A82-8035-7FE492EA34A8}.Debug|Win32.Build.0 = Debug|Win32
16 | {F5007FD4-B67B-4A82-8035-7FE492EA34A8}.Release|Win32.ActiveCfg = Release|Win32
17 | {F5007FD4-B67B-4A82-8035-7FE492EA34A8}.Release|Win32.Build.0 = Release|Win32
18 | {BF742157-DE31-4352-8638-12C109F49F3A}.Debug|Win32.ActiveCfg = Debug|Win32
19 | {BF742157-DE31-4352-8638-12C109F49F3A}.Debug|Win32.Build.0 = Debug|Win32
20 | {BF742157-DE31-4352-8638-12C109F49F3A}.Release|Win32.ActiveCfg = Release|Win32
21 | {BF742157-DE31-4352-8638-12C109F49F3A}.Release|Win32.Build.0 = Release|Win32
22 | EndGlobalSection
23 | GlobalSection(SolutionProperties) = preSolution
24 | HideSolutionNode = FALSE
25 | EndGlobalSection
26 | EndGlobal
27 |
--------------------------------------------------------------------------------
/source/cpp_training.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
9 |
10 |
12 |
13 |
15 |
16 |
18 |
19 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/source/gltop_bug1/config/vc2010/gltop_bug1.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | Win32
7 |
8 |
9 | Release
10 | Win32
11 |
12 |
13 |
14 | {F06474FB-A194-4A4F-A045-C27AF0E08418}
15 | Win32Proj
16 | gltop_bug1
17 |
18 |
19 |
20 | Application
21 | true
22 | Unicode
23 |
24 |
25 | Application
26 | false
27 | true
28 | Unicode
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 | true
42 |
43 |
44 | false
45 |
46 |
47 |
48 |
49 |
50 | Level3
51 | Disabled
52 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
53 |
54 |
55 | Console
56 | true
57 |
58 |
59 |
60 |
61 | Level3
62 |
63 |
64 | MaxSpeed
65 | true
66 | true
67 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
68 |
69 |
70 | Console
71 | true
72 | true
73 | true
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
--------------------------------------------------------------------------------
/source/gltop_bug1/config/vc2010/gltop_bug1.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
6 | h;hpp;hxx;hm;inl;inc;xsd
7 |
8 |
9 |
10 |
11 | source
12 |
13 |
14 |
--------------------------------------------------------------------------------
/source/gltop_bug1/config/xcode/gltop_bug1.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 46;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | 67FBFDEC15146EEE00145A29 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 67FBFDEB15146EEE00145A29 /* main.cpp */; };
11 | 67FBFDEE15146EEE00145A29 /* gltop_bug1.1 in CopyFiles */ = {isa = PBXBuildFile; fileRef = 67FBFDED15146EEE00145A29 /* gltop_bug1.1 */; };
12 | /* End PBXBuildFile section */
13 |
14 | /* Begin PBXCopyFilesBuildPhase section */
15 | 67FBFDE515146EEE00145A29 /* CopyFiles */ = {
16 | isa = PBXCopyFilesBuildPhase;
17 | buildActionMask = 2147483647;
18 | dstPath = /usr/share/man/man1/;
19 | dstSubfolderSpec = 0;
20 | files = (
21 | 67FBFDEE15146EEE00145A29 /* gltop_bug1.1 in CopyFiles */,
22 | );
23 | runOnlyForDeploymentPostprocessing = 1;
24 | };
25 | /* End PBXCopyFilesBuildPhase section */
26 |
27 | /* Begin PBXFileReference section */
28 | 67FBFDE715146EEE00145A29 /* gltop_bug1 */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = gltop_bug1; sourceTree = BUILT_PRODUCTS_DIR; };
29 | 67FBFDEB15146EEE00145A29 /* main.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = ""; };
30 | 67FBFDED15146EEE00145A29 /* gltop_bug1.1 */ = {isa = PBXFileReference; lastKnownFileType = text.man; path = gltop_bug1.1; sourceTree = ""; };
31 | /* End PBXFileReference section */
32 |
33 | /* Begin PBXFrameworksBuildPhase section */
34 | 67FBFDE415146EEE00145A29 /* Frameworks */ = {
35 | isa = PBXFrameworksBuildPhase;
36 | buildActionMask = 2147483647;
37 | files = (
38 | );
39 | runOnlyForDeploymentPostprocessing = 0;
40 | };
41 | /* End PBXFrameworksBuildPhase section */
42 |
43 | /* Begin PBXGroup section */
44 | 67FBFDDC15146EEE00145A29 = {
45 | isa = PBXGroup;
46 | children = (
47 | 67FBFDEA15146EEE00145A29 /* gltop_bug1 */,
48 | 67FBFDE815146EEE00145A29 /* Products */,
49 | );
50 | sourceTree = "";
51 | };
52 | 67FBFDE815146EEE00145A29 /* Products */ = {
53 | isa = PBXGroup;
54 | children = (
55 | 67FBFDE715146EEE00145A29 /* gltop_bug1 */,
56 | );
57 | name = Products;
58 | sourceTree = "";
59 | };
60 | 67FBFDEA15146EEE00145A29 /* gltop_bug1 */ = {
61 | isa = PBXGroup;
62 | children = (
63 | 67FBFDEB15146EEE00145A29 /* main.cpp */,
64 | 67FBFDED15146EEE00145A29 /* gltop_bug1.1 */,
65 | );
66 | path = gltop_bug1;
67 | sourceTree = "";
68 | };
69 | /* End PBXGroup section */
70 |
71 | /* Begin PBXNativeTarget section */
72 | 67FBFDE615146EEE00145A29 /* gltop_bug1 */ = {
73 | isa = PBXNativeTarget;
74 | buildConfigurationList = 67FBFDF115146EEE00145A29 /* Build configuration list for PBXNativeTarget "gltop_bug1" */;
75 | buildPhases = (
76 | 67FBFDE315146EEE00145A29 /* Sources */,
77 | 67FBFDE415146EEE00145A29 /* Frameworks */,
78 | 67FBFDE515146EEE00145A29 /* CopyFiles */,
79 | );
80 | buildRules = (
81 | );
82 | dependencies = (
83 | );
84 | name = gltop_bug1;
85 | productName = gltop_bug1;
86 | productReference = 67FBFDE715146EEE00145A29 /* gltop_bug1 */;
87 | productType = "com.apple.product-type.tool";
88 | };
89 | /* End PBXNativeTarget section */
90 |
91 | /* Begin PBXProject section */
92 | 67FBFDDE15146EEE00145A29 /* Project object */ = {
93 | isa = PBXProject;
94 | attributes = {
95 | LastUpgradeCheck = 0420;
96 | };
97 | buildConfigurationList = 67FBFDE115146EEE00145A29 /* Build configuration list for PBXProject "gltop_bug1" */;
98 | compatibilityVersion = "Xcode 3.2";
99 | developmentRegion = English;
100 | hasScannedForEncodings = 0;
101 | knownRegions = (
102 | en,
103 | );
104 | mainGroup = 67FBFDDC15146EEE00145A29;
105 | productRefGroup = 67FBFDE815146EEE00145A29 /* Products */;
106 | projectDirPath = "";
107 | projectRoot = "";
108 | targets = (
109 | 67FBFDE615146EEE00145A29 /* gltop_bug1 */,
110 | );
111 | };
112 | /* End PBXProject section */
113 |
114 | /* Begin PBXSourcesBuildPhase section */
115 | 67FBFDE315146EEE00145A29 /* Sources */ = {
116 | isa = PBXSourcesBuildPhase;
117 | buildActionMask = 2147483647;
118 | files = (
119 | 67FBFDEC15146EEE00145A29 /* main.cpp in Sources */,
120 | );
121 | runOnlyForDeploymentPostprocessing = 0;
122 | };
123 | /* End PBXSourcesBuildPhase section */
124 |
125 | /* Begin XCBuildConfiguration section */
126 | 67FBFDEF15146EEE00145A29 /* Debug */ = {
127 | isa = XCBuildConfiguration;
128 | buildSettings = {
129 | ALWAYS_SEARCH_USER_PATHS = NO;
130 | ARCHS = "$(ARCHS_STANDARD_64_BIT)";
131 | COPY_PHASE_STRIP = NO;
132 | GCC_C_LANGUAGE_STANDARD = gnu99;
133 | GCC_DYNAMIC_NO_PIC = NO;
134 | GCC_ENABLE_OBJC_EXCEPTIONS = YES;
135 | GCC_OPTIMIZATION_LEVEL = 0;
136 | GCC_PREPROCESSOR_DEFINITIONS = (
137 | "DEBUG=1",
138 | "$(inherited)",
139 | );
140 | GCC_SYMBOLS_PRIVATE_EXTERN = NO;
141 | GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
142 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
143 | GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
144 | GCC_WARN_ABOUT_RETURN_TYPE = YES;
145 | GCC_WARN_UNUSED_VARIABLE = YES;
146 | MACOSX_DEPLOYMENT_TARGET = 10.7;
147 | ONLY_ACTIVE_ARCH = YES;
148 | SDKROOT = macosx;
149 | };
150 | name = Debug;
151 | };
152 | 67FBFDF015146EEE00145A29 /* Release */ = {
153 | isa = XCBuildConfiguration;
154 | buildSettings = {
155 | ALWAYS_SEARCH_USER_PATHS = NO;
156 | ARCHS = "$(ARCHS_STANDARD_64_BIT)";
157 | COPY_PHASE_STRIP = YES;
158 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
159 | GCC_C_LANGUAGE_STANDARD = gnu99;
160 | GCC_ENABLE_OBJC_EXCEPTIONS = YES;
161 | GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
162 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
163 | GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
164 | GCC_WARN_ABOUT_RETURN_TYPE = YES;
165 | GCC_WARN_UNUSED_VARIABLE = YES;
166 | MACOSX_DEPLOYMENT_TARGET = 10.7;
167 | SDKROOT = macosx;
168 | };
169 | name = Release;
170 | };
171 | 67FBFDF215146EEE00145A29 /* Debug */ = {
172 | isa = XCBuildConfiguration;
173 | buildSettings = {
174 | PRODUCT_NAME = "$(TARGET_NAME)";
175 | };
176 | name = Debug;
177 | };
178 | 67FBFDF315146EEE00145A29 /* Release */ = {
179 | isa = XCBuildConfiguration;
180 | buildSettings = {
181 | PRODUCT_NAME = "$(TARGET_NAME)";
182 | };
183 | name = Release;
184 | };
185 | /* End XCBuildConfiguration section */
186 |
187 | /* Begin XCConfigurationList section */
188 | 67FBFDE115146EEE00145A29 /* Build configuration list for PBXProject "gltop_bug1" */ = {
189 | isa = XCConfigurationList;
190 | buildConfigurations = (
191 | 67FBFDEF15146EEE00145A29 /* Debug */,
192 | 67FBFDF015146EEE00145A29 /* Release */,
193 | );
194 | defaultConfigurationIsVisible = 0;
195 | defaultConfigurationName = Release;
196 | };
197 | 67FBFDF115146EEE00145A29 /* Build configuration list for PBXNativeTarget "gltop_bug1" */ = {
198 | isa = XCConfigurationList;
199 | buildConfigurations = (
200 | 67FBFDF215146EEE00145A29 /* Debug */,
201 | 67FBFDF315146EEE00145A29 /* Release */,
202 | );
203 | defaultConfigurationIsVisible = 0;
204 | };
205 | /* End XCConfigurationList section */
206 | };
207 | rootObject = 67FBFDDE15146EEE00145A29 /* Project object */;
208 | }
209 |
--------------------------------------------------------------------------------
/source/gltop_bug1/source/gltop_bug1.1:
--------------------------------------------------------------------------------
1 | .\"Modified from man(1) of FreeBSD, the NetBSD mdoc.template, and mdoc.samples.
2 | .\"See Also:
3 | .\"man mdoc.samples for a complete listing of options
4 | .\"man mdoc for the short list of editing options
5 | .\"/usr/share/misc/mdoc.template
6 | .Dd 12-3-17 \" DATE
7 | .Dt gltop_bug1 1 \" Program name and manual section number
8 | .Os Darwin
9 | .Sh NAME \" Section Header - required - don't modify
10 | .Nm gltop_bug1,
11 | .\" The following lines are read in generating the apropos(man -k) database. Use only key
12 | .\" words here as the database is built based on the words here and in the .ND line.
13 | .Nm Other_name_for_same_program(),
14 | .Nm Yet another name for the same program.
15 | .\" Use .Nm macro to designate other names for the documented program.
16 | .Nd This line parsed for whatis database.
17 | .Sh SYNOPSIS \" Section Header - required - don't modify
18 | .Nm
19 | .Op Fl abcd \" [-abcd]
20 | .Op Fl a Ar path \" [-a path]
21 | .Op Ar file \" [file]
22 | .Op Ar \" [file ...]
23 | .Ar arg0 \" Underlined argument - use .Ar anywhere to underline
24 | arg2 ... \" Arguments
25 | .Sh DESCRIPTION \" Section Header - required - don't modify
26 | Use the .Nm macro to refer to your program throughout the man page like such:
27 | .Nm
28 | Underlining is accomplished with the .Ar macro like this:
29 | .Ar underlined text .
30 | .Pp \" Inserts a space
31 | A list of items with descriptions:
32 | .Bl -tag -width -indent \" Begins a tagged list
33 | .It item a \" Each item preceded by .It macro
34 | Description of item a
35 | .It item b
36 | Description of item b
37 | .El \" Ends the list
38 | .Pp
39 | A list of flags and their descriptions:
40 | .Bl -tag -width -indent \" Differs from above in tag removed
41 | .It Fl a \"-a flag as a list item
42 | Description of -a flag
43 | .It Fl b
44 | Description of -b flag
45 | .El \" Ends the list
46 | .Pp
47 | .\" .Sh ENVIRONMENT \" May not be needed
48 | .\" .Bl -tag -width "ENV_VAR_1" -indent \" ENV_VAR_1 is width of the string ENV_VAR_1
49 | .\" .It Ev ENV_VAR_1
50 | .\" Description of ENV_VAR_1
51 | .\" .It Ev ENV_VAR_2
52 | .\" Description of ENV_VAR_2
53 | .\" .El
54 | .Sh FILES \" File used or created by the topic of the man page
55 | .Bl -tag -width "/Users/joeuser/Library/really_long_file_name" -compact
56 | .It Pa /usr/share/file_name
57 | FILE_1 description
58 | .It Pa /Users/joeuser/Library/really_long_file_name
59 | FILE_2 description
60 | .El \" Ends the list
61 | .\" .Sh DIAGNOSTICS \" May not be needed
62 | .\" .Bl -diag
63 | .\" .It Diagnostic Tag
64 | .\" Diagnostic informtion here.
65 | .\" .It Diagnostic Tag
66 | .\" Diagnostic informtion here.
67 | .\" .El
68 | .Sh SEE ALSO
69 | .\" List links in ascending order by section, alphabetically within a section.
70 | .\" Please do not reference files that do not exist without filing a bug report
71 | .Xr a 1 ,
72 | .Xr b 1 ,
73 | .Xr c 1 ,
74 | .Xr a 2 ,
75 | .Xr b 2 ,
76 | .Xr a 3 ,
77 | .Xr b 3
78 | .\" .Sh BUGS \" Document known, unremedied bugs
79 | .\" .Sh HISTORY \" Document history if command behaves in a unique manner
--------------------------------------------------------------------------------
/source/gltop_bug1/source/main.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // main.cpp
3 | // gltop_bug1
4 | //
5 | // Created by Gong Lei on 12-3-17.
6 | // Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
7 | //
8 |
9 | #include
10 |
11 | using namespace std;
12 |
13 | int main()
14 | {
15 | //声明变量,并初始化
16 | int a=010, b=10, c=0X10;
17 |
18 | //以十进制形式显示数据
19 | cout << "DEC:";
20 | cout << " a=" << a;
21 | cout << " b=" << b;
22 | cout << " c=" << c << endl;
23 |
24 | return 0;
25 | }
--------------------------------------------------------------------------------
/source/gltop_bug2/config/vc2010/Debug/CL.read.1.tlog:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gonglei007/cpp-bugs-killer/190da7cfb42d332bc9a3c25729923ef2517a7e77/source/gltop_bug2/config/vc2010/Debug/CL.read.1.tlog
--------------------------------------------------------------------------------
/source/gltop_bug2/config/vc2010/Debug/CL.write.1.tlog:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gonglei007/cpp-bugs-killer/190da7cfb42d332bc9a3c25729923ef2517a7e77/source/gltop_bug2/config/vc2010/Debug/CL.write.1.tlog
--------------------------------------------------------------------------------
/source/gltop_bug2/config/vc2010/Debug/cl.command.1.tlog:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gonglei007/cpp-bugs-killer/190da7cfb42d332bc9a3c25729923ef2517a7e77/source/gltop_bug2/config/vc2010/Debug/cl.command.1.tlog
--------------------------------------------------------------------------------
/source/gltop_bug2/config/vc2010/Debug/gltop_bug2.exe.embed.manifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/source/gltop_bug2/config/vc2010/Debug/gltop_bug2.exe.embed.manifest.res:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gonglei007/cpp-bugs-killer/190da7cfb42d332bc9a3c25729923ef2517a7e77/source/gltop_bug2/config/vc2010/Debug/gltop_bug2.exe.embed.manifest.res
--------------------------------------------------------------------------------
/source/gltop_bug2/config/vc2010/Debug/gltop_bug2.exe.intermediate.manifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/source/gltop_bug2/config/vc2010/Debug/gltop_bug2.lastbuildstate:
--------------------------------------------------------------------------------
1 | #v4.0:v100
2 | Debug|Win32|C:\Users\Administrator\Dropbox\Private\cpp_samples\|
3 |
--------------------------------------------------------------------------------
/source/gltop_bug2/config/vc2010/Debug/gltop_bug2.log:
--------------------------------------------------------------------------------
1 | Build started 2012/4/1 18:59:26.
2 | 1>Project "C:\Users\Administrator\Dropbox\Private\cpp_samples\gltop_bug2\config\vc2010\gltop_bug2.vcxproj" on node 2 (build target(s)).
3 | 1>PrepareForBuild:
4 | Creating directory "C:\Users\Administrator\Dropbox\Private\cpp_samples\Debug\".
5 | InitializeBuildStatus:
6 | Creating "Debug\gltop_bug2.unsuccessfulbuild" because "AlwaysCreate" was specified.
7 | ClCompile:
8 | C:\Program Files\Microsoft Visual Studio 10.0\VC\bin\CL.exe /c /ZI /nologo /W3 /WX- /Od /Oy- /D WIN32 /D _DEBUG /D _CONSOLE /D _UNICODE /D UNICODE /Gm /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Fo"Debug\\" /Fd"Debug\vc100.pdb" /Gd /TP /analyze- /errorReport:prompt ..\..\source\main.cpp
9 | main.cpp
10 | 1>c:\users\administrator\dropbox\private\cpp_samples\gltop_bug2\source\main.cpp : warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss
11 | ManifestResourceCompile:
12 | C:\Program Files\Microsoft SDKs\Windows\v7.0A\bin\rc.exe /nologo /fo"Debug\gltop_bug2.exe.embed.manifest.res" Debug\gltop_bug2_manifest.rc
13 | Link:
14 | C:\Program Files\Microsoft Visual Studio 10.0\VC\bin\link.exe /ERRORREPORT:PROMPT /OUT:"C:\Users\Administrator\Dropbox\Private\cpp_samples\Debug\gltop_bug2.exe" /INCREMENTAL /NOLOGO kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /MANIFEST /ManifestFile:"Debug\gltop_bug2.exe.intermediate.manifest" /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG /PDB:"C:\Users\Administrator\Dropbox\Private\cpp_samples\Debug\gltop_bug2.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:"C:\Users\Administrator\Dropbox\Private\cpp_samples\Debug\gltop_bug2.lib" /MACHINE:X86 Debug\gltop_bug2.exe.embed.manifest.res
15 | Debug\main.obj
16 | Manifest:
17 | C:\Program Files\Microsoft SDKs\Windows\v7.0A\bin\mt.exe /nologo /verbose /out:"Debug\gltop_bug2.exe.embed.manifest" /manifest Debug\gltop_bug2.exe.intermediate.manifest
18 | C:\Program Files\Microsoft SDKs\Windows\v7.0A\bin\rc.exe /nologo /fo"Debug\gltop_bug2.exe.embed.manifest.res" Debug\gltop_bug2_manifest.rc
19 | LinkEmbedManifest:
20 | C:\Program Files\Microsoft Visual Studio 10.0\VC\bin\link.exe /ERRORREPORT:PROMPT /OUT:"C:\Users\Administrator\Dropbox\Private\cpp_samples\Debug\gltop_bug2.exe" /INCREMENTAL /NOLOGO kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /MANIFEST /ManifestFile:"Debug\gltop_bug2.exe.intermediate.manifest" /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG /PDB:"C:\Users\Administrator\Dropbox\Private\cpp_samples\Debug\gltop_bug2.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:"C:\Users\Administrator\Dropbox\Private\cpp_samples\Debug\gltop_bug2.lib" /MACHINE:X86 Debug\gltop_bug2.exe.embed.manifest.res
21 | Debug\main.obj
22 | gltop_bug2.vcxproj -> C:\Users\Administrator\Dropbox\Private\cpp_samples\Debug\gltop_bug2.exe
23 | FinalizeBuildStatus:
24 | Deleting file "Debug\gltop_bug2.unsuccessfulbuild".
25 | Touching "Debug\gltop_bug2.lastbuildstate".
26 | 1>Done Building Project "C:\Users\Administrator\Dropbox\Private\cpp_samples\gltop_bug2\config\vc2010\gltop_bug2.vcxproj" (build target(s)).
27 |
28 | Build succeeded.
29 |
30 | Time Elapsed 00:00:16.89
31 |
--------------------------------------------------------------------------------
/source/gltop_bug2/config/vc2010/Debug/gltop_bug2_manifest.rc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gonglei007/cpp-bugs-killer/190da7cfb42d332bc9a3c25729923ef2517a7e77/source/gltop_bug2/config/vc2010/Debug/gltop_bug2_manifest.rc
--------------------------------------------------------------------------------
/source/gltop_bug2/config/vc2010/Debug/link-cvtres.read.1.tlog:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gonglei007/cpp-bugs-killer/190da7cfb42d332bc9a3c25729923ef2517a7e77/source/gltop_bug2/config/vc2010/Debug/link-cvtres.read.1.tlog
--------------------------------------------------------------------------------
/source/gltop_bug2/config/vc2010/Debug/link-cvtres.write.1.tlog:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gonglei007/cpp-bugs-killer/190da7cfb42d332bc9a3c25729923ef2517a7e77/source/gltop_bug2/config/vc2010/Debug/link-cvtres.write.1.tlog
--------------------------------------------------------------------------------
/source/gltop_bug2/config/vc2010/Debug/link.command.1.tlog:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gonglei007/cpp-bugs-killer/190da7cfb42d332bc9a3c25729923ef2517a7e77/source/gltop_bug2/config/vc2010/Debug/link.command.1.tlog
--------------------------------------------------------------------------------
/source/gltop_bug2/config/vc2010/Debug/link.read.1.tlog:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gonglei007/cpp-bugs-killer/190da7cfb42d332bc9a3c25729923ef2517a7e77/source/gltop_bug2/config/vc2010/Debug/link.read.1.tlog
--------------------------------------------------------------------------------
/source/gltop_bug2/config/vc2010/Debug/link.write.1.tlog:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gonglei007/cpp-bugs-killer/190da7cfb42d332bc9a3c25729923ef2517a7e77/source/gltop_bug2/config/vc2010/Debug/link.write.1.tlog
--------------------------------------------------------------------------------
/source/gltop_bug2/config/vc2010/Debug/mt.command.1.tlog:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gonglei007/cpp-bugs-killer/190da7cfb42d332bc9a3c25729923ef2517a7e77/source/gltop_bug2/config/vc2010/Debug/mt.command.1.tlog
--------------------------------------------------------------------------------
/source/gltop_bug2/config/vc2010/Debug/mt.read.1.tlog:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gonglei007/cpp-bugs-killer/190da7cfb42d332bc9a3c25729923ef2517a7e77/source/gltop_bug2/config/vc2010/Debug/mt.read.1.tlog
--------------------------------------------------------------------------------
/source/gltop_bug2/config/vc2010/Debug/mt.write.1.tlog:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gonglei007/cpp-bugs-killer/190da7cfb42d332bc9a3c25729923ef2517a7e77/source/gltop_bug2/config/vc2010/Debug/mt.write.1.tlog
--------------------------------------------------------------------------------
/source/gltop_bug2/config/vc2010/Debug/rc.command.1.tlog:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gonglei007/cpp-bugs-killer/190da7cfb42d332bc9a3c25729923ef2517a7e77/source/gltop_bug2/config/vc2010/Debug/rc.command.1.tlog
--------------------------------------------------------------------------------
/source/gltop_bug2/config/vc2010/Debug/rc.read.1.tlog:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gonglei007/cpp-bugs-killer/190da7cfb42d332bc9a3c25729923ef2517a7e77/source/gltop_bug2/config/vc2010/Debug/rc.read.1.tlog
--------------------------------------------------------------------------------
/source/gltop_bug2/config/vc2010/Debug/rc.write.1.tlog:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gonglei007/cpp-bugs-killer/190da7cfb42d332bc9a3c25729923ef2517a7e77/source/gltop_bug2/config/vc2010/Debug/rc.write.1.tlog
--------------------------------------------------------------------------------
/source/gltop_bug2/config/vc2010/Debug/vc100.idb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gonglei007/cpp-bugs-killer/190da7cfb42d332bc9a3c25729923ef2517a7e77/source/gltop_bug2/config/vc2010/Debug/vc100.idb
--------------------------------------------------------------------------------
/source/gltop_bug2/config/vc2010/Debug/vc100.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gonglei007/cpp-bugs-killer/190da7cfb42d332bc9a3c25729923ef2517a7e77/source/gltop_bug2/config/vc2010/Debug/vc100.pdb
--------------------------------------------------------------------------------
/source/gltop_bug2/config/vc2010/gltop_bug2.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | Win32
7 |
8 |
9 | Release
10 | Win32
11 |
12 |
13 |
14 |
15 |
16 |
17 | {F5007FD4-B67B-4A82-8035-7FE492EA34A8}
18 | Win32Proj
19 | gltop_bug2
20 |
21 |
22 |
23 | Application
24 | true
25 | Unicode
26 |
27 |
28 | Application
29 | false
30 | true
31 | Unicode
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 | true
45 |
46 |
47 | false
48 |
49 |
50 |
51 |
52 |
53 | Level3
54 | Disabled
55 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
56 |
57 |
58 | Console
59 | true
60 |
61 |
62 |
63 |
64 | Level3
65 |
66 |
67 | MaxSpeed
68 | true
69 | true
70 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
71 |
72 |
73 | Console
74 | true
75 | true
76 | true
77 |
78 |
79 |
80 |
81 |
82 |
--------------------------------------------------------------------------------
/source/gltop_bug2/config/vc2010/gltop_bug2.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
6 | h;hpp;hxx;hm;inl;inc;xsd
7 |
8 |
9 |
10 |
11 | source
12 |
13 |
14 |
--------------------------------------------------------------------------------
/source/gltop_bug2/config/xcode/gltop_bug2.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 46;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | 671182FC152531B2000A4A16 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 671182FB152531B2000A4A16 /* main.cpp */; };
11 | 671182FE152531B2000A4A16 /* gltop_bug2.1 in CopyFiles */ = {isa = PBXBuildFile; fileRef = 671182FD152531B2000A4A16 /* gltop_bug2.1 */; };
12 | /* End PBXBuildFile section */
13 |
14 | /* Begin PBXCopyFilesBuildPhase section */
15 | 671182F5152531B2000A4A16 /* CopyFiles */ = {
16 | isa = PBXCopyFilesBuildPhase;
17 | buildActionMask = 2147483647;
18 | dstPath = /usr/share/man/man1/;
19 | dstSubfolderSpec = 0;
20 | files = (
21 | 671182FE152531B2000A4A16 /* gltop_bug2.1 in CopyFiles */,
22 | );
23 | runOnlyForDeploymentPostprocessing = 1;
24 | };
25 | /* End PBXCopyFilesBuildPhase section */
26 |
27 | /* Begin PBXFileReference section */
28 | 671182F7152531B2000A4A16 /* gltop_bug2 */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = gltop_bug2; sourceTree = BUILT_PRODUCTS_DIR; };
29 | 671182FB152531B2000A4A16 /* main.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = ""; };
30 | 671182FD152531B2000A4A16 /* gltop_bug2.1 */ = {isa = PBXFileReference; lastKnownFileType = text.man; path = gltop_bug2.1; sourceTree = ""; };
31 | /* End PBXFileReference section */
32 |
33 | /* Begin PBXFrameworksBuildPhase section */
34 | 671182F4152531B2000A4A16 /* Frameworks */ = {
35 | isa = PBXFrameworksBuildPhase;
36 | buildActionMask = 2147483647;
37 | files = (
38 | );
39 | runOnlyForDeploymentPostprocessing = 0;
40 | };
41 | /* End PBXFrameworksBuildPhase section */
42 |
43 | /* Begin PBXGroup section */
44 | 671182EC152531B2000A4A16 = {
45 | isa = PBXGroup;
46 | children = (
47 | 671182FA152531B2000A4A16 /* gltop_bug2 */,
48 | 671182F8152531B2000A4A16 /* Products */,
49 | );
50 | sourceTree = "";
51 | };
52 | 671182F8152531B2000A4A16 /* Products */ = {
53 | isa = PBXGroup;
54 | children = (
55 | 671182F7152531B2000A4A16 /* gltop_bug2 */,
56 | );
57 | name = Products;
58 | sourceTree = "";
59 | };
60 | 671182FA152531B2000A4A16 /* gltop_bug2 */ = {
61 | isa = PBXGroup;
62 | children = (
63 | 671182FB152531B2000A4A16 /* main.cpp */,
64 | 671182FD152531B2000A4A16 /* gltop_bug2.1 */,
65 | );
66 | path = gltop_bug2;
67 | sourceTree = "";
68 | };
69 | /* End PBXGroup section */
70 |
71 | /* Begin PBXNativeTarget section */
72 | 671182F6152531B2000A4A16 /* gltop_bug2 */ = {
73 | isa = PBXNativeTarget;
74 | buildConfigurationList = 67118301152531B2000A4A16 /* Build configuration list for PBXNativeTarget "gltop_bug2" */;
75 | buildPhases = (
76 | 671182F3152531B2000A4A16 /* Sources */,
77 | 671182F4152531B2000A4A16 /* Frameworks */,
78 | 671182F5152531B2000A4A16 /* CopyFiles */,
79 | );
80 | buildRules = (
81 | );
82 | dependencies = (
83 | );
84 | name = gltop_bug2;
85 | productName = gltop_bug2;
86 | productReference = 671182F7152531B2000A4A16 /* gltop_bug2 */;
87 | productType = "com.apple.product-type.tool";
88 | };
89 | /* End PBXNativeTarget section */
90 |
91 | /* Begin PBXProject section */
92 | 671182EE152531B2000A4A16 /* Project object */ = {
93 | isa = PBXProject;
94 | attributes = {
95 | LastUpgradeCheck = 0420;
96 | };
97 | buildConfigurationList = 671182F1152531B2000A4A16 /* Build configuration list for PBXProject "gltop_bug2" */;
98 | compatibilityVersion = "Xcode 3.2";
99 | developmentRegion = English;
100 | hasScannedForEncodings = 0;
101 | knownRegions = (
102 | en,
103 | );
104 | mainGroup = 671182EC152531B2000A4A16;
105 | productRefGroup = 671182F8152531B2000A4A16 /* Products */;
106 | projectDirPath = "";
107 | projectRoot = "";
108 | targets = (
109 | 671182F6152531B2000A4A16 /* gltop_bug2 */,
110 | );
111 | };
112 | /* End PBXProject section */
113 |
114 | /* Begin PBXSourcesBuildPhase section */
115 | 671182F3152531B2000A4A16 /* Sources */ = {
116 | isa = PBXSourcesBuildPhase;
117 | buildActionMask = 2147483647;
118 | files = (
119 | 671182FC152531B2000A4A16 /* main.cpp in Sources */,
120 | );
121 | runOnlyForDeploymentPostprocessing = 0;
122 | };
123 | /* End PBXSourcesBuildPhase section */
124 |
125 | /* Begin XCBuildConfiguration section */
126 | 671182FF152531B2000A4A16 /* Debug */ = {
127 | isa = XCBuildConfiguration;
128 | buildSettings = {
129 | ALWAYS_SEARCH_USER_PATHS = NO;
130 | ARCHS = "$(ARCHS_STANDARD_64_BIT)";
131 | COPY_PHASE_STRIP = NO;
132 | GCC_C_LANGUAGE_STANDARD = gnu99;
133 | GCC_DYNAMIC_NO_PIC = NO;
134 | GCC_ENABLE_OBJC_EXCEPTIONS = YES;
135 | GCC_OPTIMIZATION_LEVEL = 0;
136 | GCC_PREPROCESSOR_DEFINITIONS = (
137 | "DEBUG=1",
138 | "$(inherited)",
139 | );
140 | GCC_SYMBOLS_PRIVATE_EXTERN = NO;
141 | GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
142 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
143 | GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
144 | GCC_WARN_ABOUT_RETURN_TYPE = YES;
145 | GCC_WARN_UNUSED_VARIABLE = YES;
146 | MACOSX_DEPLOYMENT_TARGET = 10.7;
147 | ONLY_ACTIVE_ARCH = YES;
148 | SDKROOT = macosx;
149 | };
150 | name = Debug;
151 | };
152 | 67118300152531B2000A4A16 /* Release */ = {
153 | isa = XCBuildConfiguration;
154 | buildSettings = {
155 | ALWAYS_SEARCH_USER_PATHS = NO;
156 | ARCHS = "$(ARCHS_STANDARD_64_BIT)";
157 | COPY_PHASE_STRIP = YES;
158 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
159 | GCC_C_LANGUAGE_STANDARD = gnu99;
160 | GCC_ENABLE_OBJC_EXCEPTIONS = YES;
161 | GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
162 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
163 | GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
164 | GCC_WARN_ABOUT_RETURN_TYPE = YES;
165 | GCC_WARN_UNUSED_VARIABLE = YES;
166 | MACOSX_DEPLOYMENT_TARGET = 10.7;
167 | SDKROOT = macosx;
168 | };
169 | name = Release;
170 | };
171 | 67118302152531B2000A4A16 /* Debug */ = {
172 | isa = XCBuildConfiguration;
173 | buildSettings = {
174 | PRODUCT_NAME = "$(TARGET_NAME)";
175 | };
176 | name = Debug;
177 | };
178 | 67118303152531B2000A4A16 /* Release */ = {
179 | isa = XCBuildConfiguration;
180 | buildSettings = {
181 | PRODUCT_NAME = "$(TARGET_NAME)";
182 | };
183 | name = Release;
184 | };
185 | /* End XCBuildConfiguration section */
186 |
187 | /* Begin XCConfigurationList section */
188 | 671182F1152531B2000A4A16 /* Build configuration list for PBXProject "gltop_bug2" */ = {
189 | isa = XCConfigurationList;
190 | buildConfigurations = (
191 | 671182FF152531B2000A4A16 /* Debug */,
192 | 67118300152531B2000A4A16 /* Release */,
193 | );
194 | defaultConfigurationIsVisible = 0;
195 | defaultConfigurationName = Release;
196 | };
197 | 67118301152531B2000A4A16 /* Build configuration list for PBXNativeTarget "gltop_bug2" */ = {
198 | isa = XCConfigurationList;
199 | buildConfigurations = (
200 | 67118302152531B2000A4A16 /* Debug */,
201 | 67118303152531B2000A4A16 /* Release */,
202 | );
203 | defaultConfigurationIsVisible = 0;
204 | };
205 | /* End XCConfigurationList section */
206 | };
207 | rootObject = 671182EE152531B2000A4A16 /* Project object */;
208 | }
209 |
--------------------------------------------------------------------------------
/source/gltop_bug2/source/gltop_bug2.1:
--------------------------------------------------------------------------------
1 | .\"Modified from man(1) of FreeBSD, the NetBSD mdoc.template, and mdoc.samples.
2 | .\"See Also:
3 | .\"man mdoc.samples for a complete listing of options
4 | .\"man mdoc for the short list of editing options
5 | .\"/usr/share/misc/mdoc.template
6 | .Dd 12-3-30 \" DATE
7 | .Dt gltop_bug2 1 \" Program name and manual section number
8 | .Os Darwin
9 | .Sh NAME \" Section Header - required - don't modify
10 | .Nm gltop_bug2,
11 | .\" The following lines are read in generating the apropos(man -k) database. Use only key
12 | .\" words here as the database is built based on the words here and in the .ND line.
13 | .Nm Other_name_for_same_program(),
14 | .Nm Yet another name for the same program.
15 | .\" Use .Nm macro to designate other names for the documented program.
16 | .Nd This line parsed for whatis database.
17 | .Sh SYNOPSIS \" Section Header - required - don't modify
18 | .Nm
19 | .Op Fl abcd \" [-abcd]
20 | .Op Fl a Ar path \" [-a path]
21 | .Op Ar file \" [file]
22 | .Op Ar \" [file ...]
23 | .Ar arg0 \" Underlined argument - use .Ar anywhere to underline
24 | arg2 ... \" Arguments
25 | .Sh DESCRIPTION \" Section Header - required - don't modify
26 | Use the .Nm macro to refer to your program throughout the man page like such:
27 | .Nm
28 | Underlining is accomplished with the .Ar macro like this:
29 | .Ar underlined text .
30 | .Pp \" Inserts a space
31 | A list of items with descriptions:
32 | .Bl -tag -width -indent \" Begins a tagged list
33 | .It item a \" Each item preceded by .It macro
34 | Description of item a
35 | .It item b
36 | Description of item b
37 | .El \" Ends the list
38 | .Pp
39 | A list of flags and their descriptions:
40 | .Bl -tag -width -indent \" Differs from above in tag removed
41 | .It Fl a \"-a flag as a list item
42 | Description of -a flag
43 | .It Fl b
44 | Description of -b flag
45 | .El \" Ends the list
46 | .Pp
47 | .\" .Sh ENVIRONMENT \" May not be needed
48 | .\" .Bl -tag -width "ENV_VAR_1" -indent \" ENV_VAR_1 is width of the string ENV_VAR_1
49 | .\" .It Ev ENV_VAR_1
50 | .\" Description of ENV_VAR_1
51 | .\" .It Ev ENV_VAR_2
52 | .\" Description of ENV_VAR_2
53 | .\" .El
54 | .Sh FILES \" File used or created by the topic of the man page
55 | .Bl -tag -width "/Users/joeuser/Library/really_long_file_name" -compact
56 | .It Pa /usr/share/file_name
57 | FILE_1 description
58 | .It Pa /Users/joeuser/Library/really_long_file_name
59 | FILE_2 description
60 | .El \" Ends the list
61 | .\" .Sh DIAGNOSTICS \" May not be needed
62 | .\" .Bl -diag
63 | .\" .It Diagnostic Tag
64 | .\" Diagnostic informtion here.
65 | .\" .It Diagnostic Tag
66 | .\" Diagnostic informtion here.
67 | .\" .El
68 | .Sh SEE ALSO
69 | .\" List links in ascending order by section, alphabetically within a section.
70 | .\" Please do not reference files that do not exist without filing a bug report
71 | .Xr a 1 ,
72 | .Xr b 1 ,
73 | .Xr c 1 ,
74 | .Xr a 2 ,
75 | .Xr b 2 ,
76 | .Xr a 3 ,
77 | .Xr b 3
78 | .\" .Sh BUGS \" Document known, unremedied bugs
79 | .\" .Sh HISTORY \" Document history if command behaves in a unique manner
--------------------------------------------------------------------------------
/source/gltop_bug2/source/main.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // main.cpp
3 | // gltop_bug2
4 | //
5 | // Created by Gong Lei on 12-3-30.
6 | // Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
7 | //
8 |
9 | #include
10 |
11 | class BaseObject
12 | {
13 | public:
14 | unsigned int mType;
15 | };
16 |
17 | class ObjectA : public BaseObject
18 | {
19 | public:
20 | ObjectA():
21 | mState(2)
22 | {
23 | mType = 1;
24 | }
25 |
26 | int mState;
27 | };
28 |
29 | class ObjectB : public BaseObject
30 | {
31 | public:
32 | ObjectB():
33 | mFlag(4)
34 | {
35 | mType = 3;
36 | }
37 |
38 | char mFlag;
39 | };
40 |
41 | int main (int argc, const char * argv[])
42 | {
43 | ObjectA a1;
44 | ObjectA a2;
45 | ObjectB b1;
46 | ObjectB b2;
47 |
48 | BaseObject* objectList[] = { &a1, &a2, &b1, &b2 };
49 |
50 | ObjectA* objA = &a2;
51 | int* state = &objA->mState + 1;
52 | *state = 10;
53 |
54 | // insert code here...
55 | std::cout << "a1:type-" << a1.mType << "state-" << a1.mState << "\n";
56 | std::cout << "a2:type-" << a2.mType << "state-" << a2.mState << "\n";
57 | std::cout << "b1:type-" << b1.mType << "flag-" << (int)b1.mFlag << "\n";
58 | std::cout << "b2:type-" << b2.mType << "flag-" << (int)b2.mFlag << "\n";
59 | return 0;
60 | }
61 |
62 | // 内存越界
63 | // 栈的地址空间
64 |
65 |
--------------------------------------------------------------------------------