随笔分类 - C
摘要:1.scons是神马?scons是linux下的自动构建工具,类似cmake。2. 安装wget http://prdownloads.sourceforge.net/scons/scons-2.2.0.tar.gz .tar zxvfscons-2.2.0.tar.gzcdscons-2.2.0python setup.py install正常情况下,scons将安装到${PYTHON_INSTALL_DIR}/bin/下3. hello world程序三个文件hello.h hello.c main.c hello.h定义函数void hello(); hello.c中实现该函数,main
阅读全文
摘要:1. 编译boost类库2. 设置vs2010的环境<1>. 编译boost类库前面一篇文章介绍了如何在linux下建立boost的开发环境,并且编写了一个测试程序,这里将试着在windows下编译boost,同时设置vs2010的开发环境,使用vs来作为开发的ide。1. 下载bjam.exe/Files/xuqiang/bjam.rar2. 编译boost将下载的bjam.exe放置在boost源代码的目录下,简单的编译的话,直接双击bjam.exe即可,开始编译,这个过程可能持续时间比较长。3. 编译完成之后,安装boost,下面的命令将boost安装到e:\boost目录下
阅读全文
摘要:1. 没有makefile的日子2. 参考资料及代码下载<1>. 没有makefile的日子[上一篇]中介绍了makefile的编写规则,第一个标题是“没有makefile的日子”,收到[博客园]的网友zhuangzhuang1988的回复可以使用automake来自动生成makefile。如果在linux下从源代码安装过程序的话,通常的过程是这样:./configure; make; make install下面我们将试图如何生成这种发行版本,这里面主要使用到了aclocal, automake等工具。1. 现在假设程序源代码已经编写完成,这里是main.cxuqiang@ubu
阅读全文
摘要:1. 没有makefile的日子 1.1 手动编译 1.2 文件编译依赖树2. 快速体验makefile3. makefile 变量4. makefile条件编译5. makefile函数6. 参考资料<1>. 没有makefile的日子1.1 程序是如何编译的?如果存在这么一个工程目录结构:.|-- foo.c|-- foo.h|-- main.c如果想要编译上面的工程,在没有使用makefile的情况下,可能需要使用如下的编译命令:xuqiang@ubuntu:~/makefile/program$ cc -c foo.c foo.h # 编译foo.oxuqiang@ubun
阅读全文
摘要:1. 使用gdb调试程序 1.1 编译源代码 1.2 如何进入,退出gdb 1.3 浏览源代码 1.3.1 list命令 1.3.2 如何在gdb查找字符串 1.4 break point断点 1.4.1 设置断点 1.4.2 删除断点 1.4.3 查看断点信息 1.5 watch point监视点 1.5.1 设置监视点 1.5.2 查看监视变量的内容 1.6catchpoints 1.7让程序运行起来 1.8 查看变量2. clewn 2.1 安装 2.2 简单使用3. ddd 3.1 安装 3.2 使用4. 相关文件下载及参考资料<1>. 使用gdb调试程序1.1 编译源代码
阅读全文
摘要:1. io操作实例2. io函数分析<1>. io 操作实例1.1 文本文件读取#include <stdio.h> // file io operators#include <stdlib.h>int main(int argc, char* argv[]){ FILE* fp; int ch; long int count = 0; if (argc != 2) { printf("usage : %s filename", argv[0]); return EXIT_SUCCESS; } // open file if ( (fp
阅读全文
摘要:1. 副作用和顺序点2. 输出输出缓冲区3. 变量的声明和变量定义4. 函数指针5. const和define6. 存储类,链接和内存管理<1>. 副作用side effect和顺序点sequence point;1.1 side effect和sequence point对于下面的语句state = 10;我们认为这是一个表达式(赋值语句在c语言中是表达式),表达式的值即是10,那么从何而来副作用?我们说c语言对于state = 10;的处理仅仅是想得到该语句的值,但是在计算该表达式值的过程中无意将state变量的值改变掉了,这既是所谓的side effect。有了side ef
阅读全文
摘要:1. 先来看看效果图2. 配置方法<1>.效果图下面的效果如如果没有特殊说明,均是不需要按代码提示的快捷键(例如ctrl+p等)的,看看效果,是不是很想visual assist。1.1 结构struct和枚举enum代码提示:1.2 用户定义函数代码提示1.3 用户定义变量代码提示1.4 c++ class method代码提示:1.5 class属性代码提示1.6 c library代码提示<2>.配置方法2.1 安装ctags并生成tag文件安装ctagsxuqiang@ubuntu:~/Documents/vim/test$ sudo apt-get insta
阅读全文
摘要:1. vs2008如何检查内存泄漏?2. Linux下如何检查c++程序内存泄漏?1. vs2008如何检查内存泄漏?vs2008中检查内存泄漏是比较简单的。新建一个win32console application,包含如下的头文件:#define _CRTDBG_MAP_ALLOC#include <stdlib.h>#include <crtdbg.h>通过包含#include <crtdbg.h>,将malloc和free映射成_malloc_dbg和_free_dbg,而这两个函数负责跟踪内存的申请和内存的释放。测试下面的程序:#define _CR
阅读全文
摘要:codeblock代码提示加速如此简单:
阅读全文
摘要:1. 下载boost c++库(http://www.boost.org/),这里使用的是1.46.1版本的。2. 在linux下进行简单编译。2.1 解压该文件,解压完成后目录如下:2.2 在boost的跟目录执行如下命令开始配置:2.3 上面的过程完成之后,开始编译boost库:2.4 经过漫长的过程(如果按照山谜案的默认的配置的话,时间真的很长),完成boost的编译。其中可能出现的错误: 1.error: bzlib.h: No such file or directory boost,解决方法,boost编译时需要依赖libbz2库:sudo apt-get install libb
阅读全文
摘要:You need to use theexportkeyword. However, I don't think G++ has proper support, so you need to include the template function's definition in the header so the translation unit can use it. This is because the<int>'version' of the template hasn't been created, only t
阅读全文
摘要:void func ( int (&arr)[10] ){}int main (){ int arr[10]; func(arr); return 0;}
阅读全文
摘要:http://uncrustify.sourceforge.net/Ident code, aligning on parens, assignments, etcAlign on '=' and variable definitionsAlign structure initializersAlign #define stuffAlign backslash-newline stuffReformat comments (a little bit)Fix inter-character spacingAdd or remove parens on return stateme
阅读全文
摘要:在gcc的编译器上使用bool值的话需要使用包含头文件<stdbool.h>如果直接使用编译器会报错。查看<stdbool.h>可以看到其实bool值只是一个define得常量true 1false 0
阅读全文
摘要://////////////////////////////////////////////////////////////////////////// TUPLE COMPLETE CORRECT///////////////////////////////////////////////////////////////////////////************************************************************************** TypeOperator Definition******************
阅读全文
摘要:went to "Project | Game Properties | Configuration Properties | C/C++ | Code Generation | Runtime Library"and set Multi-threaded Debug (/MTd)did build generated error messages...then reset"Project | Game Properties | Configuration Properties | C/C++ | Code Generation | Runtime Library
阅读全文