This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Use of assert() function in C

In my search for new strategeis for writing bug free embedded code and debugging the code quickly, I came across about assert() function. By simple googling i found it as useful to find which expression (or) variable (or) line of code made my code not to work as defined.

Quickly i tried a simple test code in keil. But it did not show me any error message.

Help me regarding why i am not able get any error message. Also i recognised (in dis-assembly window) that the code continue to execute different library functions and never come out.
Given below is my test code.

#include <assert.h>

int myfunc (int arg)
{
        arg=0;
        return(arg);
}
void child_func (int arg1)
{
        ;
}

int main(void)
{
        short int temp_var=0;

        while(1)
        {
                int temp_var1;
                temp_var1=myfunc(temp_var);
                assert(temp_var1!=0);
                child_func(temp_var1);

        }
}

0