今天看书碰到了一个assert函数,我找遍了vc的类库大全,就找不到对这函数的定义,我知道有 宏ASSERT这东东,但assert这是哪个类库的,请高手告知,vc是区分大小写的

解决方案 »

  1.   

    assert
    Evaluates an expression and when the result is FALSE, prints a diagnostic message and aborts the program.void assert( int expression );Routine Required Header Compatibility 
    assert <assert.h> ANSI, Win 95, Win NT 
    For additional compatibility information, see Compatibility in the Introduction.LibrariesLIBC.LIB Single thread static library, retail version 
    LIBCMT.LIB Multithread static library, retail version 
    MSVCRT.LIB Import library for MSVCRT.DLL, retail version 
    Return ValueNoneParameterexpressionExpression (including pointers) that evaluates to nonzero or 0
    ======================================================================
    ASSERT
    ASSERT( booleanExpression )ParametersbooleanExpressionSpecifies an expression (including pointer values) that evaluates to nonzero or 0.
      

  2.   

    assert()是Ansi C标准函数。他如果assert()的条件为false,在Debug版本中会弹出对话框,警告你是哪一行出现了assert错误。在release版本中则assert()被定义成空函数。例如assert(i < 10); 运行到这个语句时,如果i >= 10,则会弹出assert为假的警告。此时如果忽略则程序继续运行。这个assert()函数主要时为了调试程序方便用的呵呵,不过不要小看它,它是契约思想的重要一部分。
      

  3.   

    呵呵,我旁边的同事说,“欢迎到我们Arima来看代码,到处是assert”。^_^