VC语言

本类阅读TOP10

·VC++ 学习笔记(二)
·用Visual C++打造IE浏览器(1)
·每个开发人员现在应该下载的十种必备工具
·教你用VC6做QQ对对碰外挂程序
·Netmsg 局域网聊天程序
·Windows消息大全
·VC++下使用ADO编写数据库程序
·VC++学习笔记(四)
·非法探取密码的原理及其防范
·怎样在VC++中访问、修改注册表

分类导航
VC语言Delphi
VB语言ASP
PerlJava
Script数据库
其他语言游戏开发
文件格式网站制作
软件工程.NET开发
C++技巧之五

作者:未知 来源:月光软件站 加入时间:2005-2-28 月光软件站

 

 
 
 
// Original do/while Macro 
//原始的do/while
 
#define MY_ASSERT_ONE(x) do { \
                    if (!(x)) {\
                                       _asm int 3 \
                    } \
                    }  while(0)
 
// new Macro that removes the loop 
// 新宏移去了loop
 
#define MY_ASSERT_ONE(x) { \
                    if (!(x)) {  \
                                         _asm int 3  \
                    } \
                    }

 

代码清单 4 避免一个编译器错误

 
(a). /* This code will cause a compile error */
/* 此段代码将产生一个编译器错误 */
void main(void)
{
                    int i = 10;
                   printf("i: %d\n", i);
                    int j = 100;  /* This statement will cause a compiler error since
                                            it was not declared at the top of the function. */
/* 此语句将导致一个编译器错误,
因为它未在函数顶部声明过。 */
 
                    printf("j: %d\n", j);
}
 
(b). /* whereas this code will not */
/*而此段代码将不产生一个编译器错误*/
void main(void)
{
                    int i = 10;
                    printf("i: %d\n", i);
                    {
                                         int j = 100;            /* This statement is fine since it is akin
                                                                                 to defining a local function within the function.  */
/* 此语句很精炼,
因为它在函数中定义了一局部函数的同族。*/
                                         printf("j: %d\n", j);
                    }
}


相关文章

相关软件