Websydian v6.1 online documentationOnline documentation - Websydian v6.1

FAQ - "fatal error C1509: compiler limit: too many exception handler states in function"

Product Websydian
Version All
Category Development
Question We receive "fatal error C1509: compiler limit: too many exception handler states in function"
Answer The Visual C++ compiler has an upper limit to how complex a function can be. We do not exactly know what causes the upper limit to be reached, but the only solution is to simplify the function.


You have the following ways to simplify the EventDispatcher function:
 

  1. Remove EventHandler functions from the EventDispatcher
    Look through all the EventHandler functions and remove those that are no longer used. You can also see if it is possible to reuse some of the EventHandler functions by using the comprise triple. E.g. a Logout event or a 'Back to Main' event will typically contain the same functionality no matter what PageGenerator function they belong to.
    An EventHandler function can be reused by using the triple PageGenerator FNC comprise FNC EventHandler.
  2. Create 2 EventDispatcher functions
    Each EventDispatcher would then call a set of EventHandler functions. To control this you must then create a wrapper function that only contains logic that determines which EventDispatcher function to call.
    It is then the wrapper functions you should generate and build as an executable function and NOT the 2 EventDispatcher functions.
  3. Change the EventDispatcher to use dynamic calls
    This means that you with a little source code calls the EventHandler DLL function that has the name that is in the field WebInput<EventID>. For security reasons it is VERY important that you before the call verify that the EventID field contains a valid EventHandler name. This check could be accomplished by a lookup in a database table.

 

Solution #2 is the fastest while #3 is better as it will work no matter how many EventHandler functions you have. The latter also has the advantage that the EventHandler function to call is found in constant time as opposed to the standard way where the EventHandler function is found using a big If-Else construct.