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

how to realize exit(0) function in keilC51

HI: We can use exit(0) instruction to exit a normally running routine in C language. But exit(0) is not being in the KEILC51.Now how can I realize the same function as exit(0) instruction with other instructions?

Parents
  • It is possible to realize the function exit(0).

    No, it's not, because like with all functions defined by the standard,

    and decide what you want it to do.

    is not an option. The C Standard defines what exit() does. If you're going to implement a function that does something else, you are for practical intents and purposes forbidden to call that function exit().

    And there's quite exactly no way to fulfill the standard's requirement for exit() on an 8051, of all things. C on a '51 is, pretty much necessarily, a free-standing implementation, as opposed to a hosted one. As such, a C51 program is forbidden to call exit() because <stdlib.h> is not among the headers listed in C99, chapter 4, paragraph 6. And because there is no "host environment" to return to.

Reply
  • It is possible to realize the function exit(0).

    No, it's not, because like with all functions defined by the standard,

    and decide what you want it to do.

    is not an option. The C Standard defines what exit() does. If you're going to implement a function that does something else, you are for practical intents and purposes forbidden to call that function exit().

    And there's quite exactly no way to fulfill the standard's requirement for exit() on an 8051, of all things. C on a '51 is, pretty much necessarily, a free-standing implementation, as opposed to a hosted one. As such, a C51 program is forbidden to call exit() because <stdlib.h> is not among the headers listed in C99, chapter 4, paragraph 6. And because there is no "host environment" to return to.

Children
  • "No, it's not, because like with all functions defined by the standard"

    It is a rule of a standard, it should not be confused with some law of physics.

    A sign saying "no entry" does not do anything to physically stop someone driving up a road the wrong way.

    
    #define BEGIN }
    #define END   {
    
    void main(void)
    END
       ;
    BEGIN
    
    

    Looks crazy, stupid etc, but you can still do it.