Menu

Exception handling

Developers
G. Sfiris
2014-09-08
2014-09-08
  • G. Sfiris

    G. Sfiris - 2014-09-08

    Hello all,

    I see that there is no exception handling, except for OPC Module. Is this a coding policy? I mean not to use exceptions?

    Best Regards,
    Giorgis Sfiris

     
  • Zoitl Alois

    Zoitl Alois - 2014-09-08

    Hi,

    yes, as exception support add significantly to the size of the executable and to the stack consumption but also add has some run-time overhead we decided not to use exception in the core code and in all code that is used on all platforms especially the small ones.

    Alois

     
  • G. Sfiris

    G. Sfiris - 2014-09-08

    Hello,

    this makes sense. Do I also have to minimize error checking? In particular I wanted to check if a vector.push_back() worked or not. To do that without exceptions I have to check if the vector.back() is the item I inserted. Is this too much to check? Is it better to skip such checks and assume everything goes right to save resources and CPU cycles?

    Cheers,
    Giorgis

     
  • Zoitl Alois

    Zoitl Alois - 2014-09-08

    Hi,

    This is a quite tricky question. I would say do as much checking as necessary to allow a save operation. But consider also the critical paths. In our case the critical path is often the path taken during full operation (e.g., handling the request event). While non critical paths are during (de-)initialization (i.e., INIT(+/-)). So doing additional checks there can relive you from some checks in the critical path.

    BTW if you are going to smaller embedded systems with non Linux or Windows operating systems (e.g., eCOS) you may face problems when using STL. Therefore we have our own very simple list implementation in FORTE