
C/C++
文章平均质量分 78
firetoucher
这个作者很懒,什么都没留下…
展开
-
菜鸟学C++
2004/7/2------------------------------------------------------------------------------------------how to debug register?here is a example:typedef struct regs_t{ DWORD eax; DWORD ebx; DWORD ecx; DWOR原创 2004-11-23 10:30:00 · 1496 阅读 · 0 评论 -
关于pointer-to-member的一些讨论
今天为了测试data member pointer,在BCB6里写了一段程序,却发现了一点问题。代码很简单:struct Base1 { int val1;};printf("&Base1::val1 = %p, %d/n", &Base1::val1, 2);结果发现数字2 输出失败,显示为0,察看CPU发现:0040116B 6A02 push 0x0200原创 2006-01-08 22:03:00 · 3197 阅读 · 10 评论 -
for初始语句中声明变量的作用域问题
[论坛链接]在for的初始语句中声明的变量,按C++98标准的规定,有效期仅为for循环中,详见ISO-IEC14882:6.5.3 The for statement [stmt.for]3 If the for-init-statement is a declaration, the scope of the name(s) declared extends to the end原创 2006-02-28 13:29:00 · 4668 阅读 · 0 评论 -
[C++想当然]线程不安全的local static variable
案例程序在多线程执行时,会发生random crash。结果跟踪到是多线程并发调用下面函数时出现非法操作: class ElementMap { static Type find (const std::string& name) { static ElementMap emap; Type type = UNKNOWN;原创 2007-08-31 16:17:00 · 5251 阅读 · 2 评论 -
C语言的静态映射声明
前段时间,准备设计一个关于出错信息的表,每一个错误有一个唯一的ErrID,和对应的错误信息以及其他辅助信息。在C语言中,很自然的实现如下:enum { ERR_ID_1, ERR_ID_2, ERR_ID_3, ERR_ID_4} ErrID;const char* errmsg[] = { "This is Error 1 msg", /*ERR_ID_1*原创 2007-11-13 15:05:00 · 3631 阅读 · 0 评论