
C++
翁志艺
这个作者很懒,什么都没留下…
展开
-
c++11 多线程
[code="c++"]#include #include #include #include std::mutex g_lock; void func(){ g_lock.lock(); std::cout原创 2013-10-19 18:35:24 · 223 阅读 · 0 评论 -
C++宏#号的用法
1. #:在宏展开的时候会将#后面的参数替换成字符串,如: #define p(exp) printf(#exp); 调用p(hello)的时候会将#exp换成”hello”The # operator should not be confused with the null directive.Use the # operator in a ...原创 2013-10-19 18:52:07 · 236 阅读 · 0 评论 -
memcpy和memmove
函数原型:void *memcpy(void *dest, const void *src, size_t n)void *memmove(void *dest, const void *src, size_t n)两者的功能基本相同,唯一不同的是,当 dest 和 src 有重叠的时候选用不同的函数可能会造成不同的结果。memcpy的原理是从src的低地址开始到高...原创 2013-10-19 19:57:19 · 173 阅读 · 0 评论 -
linux的线程栈大小的限制导致的段错误
[code="c++"]#include #include int main(){ int a [10 * 1024 * 1024]; a[0] = 1; return 0;}[/code]上面的代码运行就会crash。原因:ulimit -s10240可以看到linux配置的线程栈的大小为10M。函数里面使用...原创 2013-10-22 21:29:48 · 892 阅读 · 0 评论 -
mudos解释器中lpc数组==操作的代码分析
[code="lpc"]void main(){ debug_message("%O","hello" == "hello"); debug_message("%O",[1,2]==[1,2]);}[/code]这段lpc代码会输出什么呢?我们先从字节码分析吧。[quote]STRINGS: 0: a.c 1: %O...原创 2013-11-16 17:19:51 · 318 阅读 · 0 评论 -
mudos解释器中lpc数组-=操作的代码分析
[code="lpc"]void main(){ mixed a = [1]; a += [2]; a += ["hello"]; a += [[1,2]]; a -= [2]; a -= ["hello"]; a -= [[1,2]]; debug_message("%O",a);}[/code]...2013-11-16 17:33:46 · 332 阅读 · 0 评论 -
boost::enable_shared_from_this分析
[color=red][size=medium]为什么需要boost::enable_shared_from_this?[/size][/color][code="c++"]class cat{};shared_ptr p(new cat);shared_ptr p2(p);class cat:public boost::enable_shared_from...原创 2013-02-20 14:01:58 · 168 阅读 · 0 评论 -
判断系统的字节顺序
Why Worry About Byte OrderIn general, the underlying byte order of the processor is completely transparent to the programmer. However, there can be a problem, for example, when data is exchanged w...原创 2013-03-02 21:56:57 · 167 阅读 · 0 评论