Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

assert: change the do-while of assert to a conditional expression #6

Closed
wants to merge 2 commits into from

Commits on Feb 20, 2024

  1. assert: change the do-while of assert to a conditional expression

    According to the standard definition, assert should return a void expression
    https://pubs.opengroup.org/onlinepubs/007904875/basedefs/assert.h.html
    
    This patch involves two changes:
    
    If you define the NDEBUG macro, assert does not use any parameters and directly returns a void expression.
    assert should return a void expression and cannot use do-while statements.
    If the following code , a compilation error will occur.
    
    Signed-off-by: yinshengkai <[email protected]>
    Gary-Hobson committed Feb 20, 2024
    Configuration menu
    Copy the full SHA
    122c2db View commit details
    Browse the repository at this point in the history

Commits on Feb 21, 2024

  1. assert: When defining NDEBUG, do not use macro parameters

    The implementation of assert in linux is as follows:
    
    After defining NDEBUG in sqlite, some variables will be undefined,
    and referencing variables in assert will cause compilation errors.
    
    sqlite3.c:28729:23: error: ‘mutexIsInit’ undeclared (first use in this function)
    28729 |   assert( GLOBAL(int, mutexIsInit) );
    
    Signed-off-by: yinshengkai <[email protected]>
    Gary-Hobson committed Feb 21, 2024
    Configuration menu
    Copy the full SHA
    231775c View commit details
    Browse the repository at this point in the history