File tree Expand file tree Collapse file tree 1 file changed +1
-1
lines changed Expand file tree Collapse file tree 1 file changed +1
-1
lines changed Original file line number Diff line number Diff line change @@ -423,7 +423,7 @@ static int lept_parse_value(lept_context* c, lept_value* v) {
423423
424424断言(assertion)是 C 语言中常用的防御式编程方式,减少编程错误。最常用的是在函数开始的地方,检测所有参数。有时候也可以在调用函数后,检查上下文是否正确。
425425
426- C 语言的标准库含有 ` assert() `  这个宏(需 ` #include <assert.h> ` ),提供断言功能。当程序以 release 配置编译时(定义了 ` NDEBUG `  宏),` assert() `  不会做检测;而当在 debug 配置时(没定义 ` NDEBUG `  宏),则会在运行时检测 ` assert(cond) `  中的条件是否为真(非 0),断言失败会直接令程序崩溃。
426+ C 语言的标准库含有 [ ` assert() ` ] ( http://en.cppreference.com/w/c/error/assert )  这个宏(需 ` #include <assert.h> ` ),提供断言功能。当程序以 release 配置编译时(定义了 ` NDEBUG `  宏),` assert() `  不会做检测;而当在 debug 配置时(没定义 ` NDEBUG `  宏),则会在运行时检测 ` assert(cond) `  中的条件是否为真(非 0),断言失败会直接令程序崩溃。
427427
428428例如上面的 ` lept_parse_null() `  开始时,当前字符应该是 ` 'n' ` ,所以我们使用一个宏 ` EXPECT(c, ch) `  进行断言,并跳到下一字符。
429429
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments