[Beremiz-devel] [matiec][patch] Fix for greatest_tick_count__ calculation error.

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[Beremiz-devel] [matiec][patch] Fix for greatest_tick_count__ calculation error.

Beremiz-Devel mailing list
Hi, Alexandr, Mario.

I have fixed greatest_tick_count__ calculation error. Now greatest_tick_count__ is common multiple of all tasks tick counts.

The actual problem is deeper, because we need statefull timers to handle task scheduling on the high level, but at least we now can have correct greatest_tick_count__.

I'sorry but my text editor have "fixed" some more things...

Best regards,
Paul Beltyukov

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Beremiz-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beremiz-devel

matiec_greatest_tick_count_fix.patch (77K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [Beremiz-devel] [matiec][patch] Fix for greatest_tick_count__ calculation error.

Beremiz-Devel mailing list
On 18-04-23 12:37, [hidden email] wrote:

> Hi, Alexandr, Mario.
>
> I have fixed greatest_tick_count__ calculation error. Now
> greatest_tick_count__ *is* common multiple of all tasks tick counts.
>
> The actual problem is deeper, because we need *statefull timers* to handle
> task scheduling on the high level, but at least we now can have correct
> greatest_tick_count__.
>
> I'sorry but my text editor have "fixed" some more things...
Hi Paul,

if you want to fix code-style warning, I'd recommend you at least to
separate fix of the real problem and fix of code-style. The change
should be easy to read and fix only *one* problem.
Please separate changes, this is not that hard in every editor.


> Best regards,
> Paul Beltyukov

> # HG changeset patch
> # User Paul Beltyukov
> # Date 1524462097 -18000
> #      Mon Apr 23 10:41:37 2018 +0500
> # Node ID 16d239d787731066c4879ead29e1374459e1c876
> # Parent  2dc67df52e5935b16aa93219bfcc558253a41759
> Fixed erronious greatest_tick_count__ calculation.
>
> diff -r 2dc67df52e59 -r 16d239d78773 stage4/generate_c/generate_c.cc
> --- a/stage4/generate_c/generate_c.cc Fri Apr 20 17:40:29 2018 +0100
> +++ b/stage4/generate_c/generate_c.cc Mon Apr 23 10:41:37 2018 +0500
> @@ -30,6 +30,7 @@
>  #include <map>
>  #include <sstream>
>  #include <strings.h>
> +#include <climits>
>  
>  
>  #include "../../util/symtable.hh"
> @@ -54,7 +55,7 @@
>  
>  /* Macros to access the constant value of each expression (if it exists) from the annotation introduced to the symbol_c object by constant_folding_c in stage3! */
>  #define VALID_CVALUE(dtype, symbol)           ((symbol)->const_value._##dtype.is_valid())
> -#define GET_CVALUE(dtype, symbol)             ((symbol)->const_value._##dtype.get())
> +#define GET_CVALUE(dtype, symbol)             ((symbol)->const_value._##dtype.get())
>  
>  
>  
> @@ -184,7 +185,7 @@
>  /* Parse command line options passed from main.c !! */
>  #include <stdlib.h> // for getsubopt()
>  int  stage4_parse_options(char *options) {
> -  enum {LINE_OPT = 0,  
> +  enum {LINE_OPT = 0,
>          SEPTFILE_OPT,
>          BACKUP_OPT    /* option to generate function to backup and restore internal PLC state */
>          /*, SOME_OTHER_OPT, YET_ANOTHER_OPT */};
> @@ -195,7 +196,7 @@
>          /* SOME_OTHER_OPT, ...             */
>          NULL };
>    /* unfortunately, the above commented out syntax for array initialization is valid in C, but not in C++ */
> -  
> +
>    char *subopts = options;
>    char *value;
>    int opt;
> @@ -207,23 +208,23 @@
>        case   BACKUP_OPT: generate_plc_state_backup_fuctions__  = 1; break;
>        default          : fprintf(stderr, "Unrecognized option: -O %s\n", value); return -1; break;
>       }
> -  }    
> +  }
>    return 0;
>  }
>  
>  
>  void stage4_print_options(void) {
> -  printf("          (options must be separated by commas. Example: 'l,w,x')\n");
> -  printf("      l : insert '#line' directives in generated C code.\n");
> -  printf("      p : place each POU in a separate pair of files (<pou_name>.c, <pou_name>.h).\n");
> -  printf("      b : generate functions to backup and restore internal PLC state.\n");
> +  printf("          (options must be separated by commas. Example: 'l,w,x')\n");
> +  printf("      l : insert '#line' directives in generated C code.\n");
> +  printf("      p : place each POU in a separate pair of files (<pou_name>.c, <pou_name>.h).\n");
> +  printf("      b : generate functions to backup and restore internal PLC state.\n");
>  }
>  #else /* not __unix__ */
> -/* getsubopt isn't supported with mingw,
> +/* getsubopt isn't supported with mingw,
>   *  then stage4 options aren't available on windows*/
>  void stage4_print_options(void) {}
>  int  stage4_parse_options(char *options) {return 0;}
> -#endif
> +#endif
>  
>  /***********************************************************************/
>  /***********************************************************************/
> @@ -253,10 +254,10 @@
>  /***********************************************************************/
>  
>  /* A helper class that prints out the identifiers for function calls to overloaded functions */
> -/* Given a function declaration of the function being called, it
> +/* Given a function declaration of the function being called, it
>   * will simply print out the returned data type,
>   * followed by the data types of all input, output, and in_out parameters.
> - *   for e.g.;
> + *   for e.g.;
>   *     SIN( REAL) : REAL      -> prints out ->  REAL__REAL
>   *     LEN( STRING) : INT     -> prints out ->  INT__STRING
>   *     MUL(TIME, INT) : TIME  -> prints out ->  TIME__TIME__INT
> @@ -266,20 +267,20 @@
>      symbol_c *current_type;
>      bool_type_name_c tmp_bool;
>  
> -    void print_list(symbol_c *var_list, symbol_c *data_type) {
> +    void print_list(symbol_c *var_list, symbol_c *data_type) {
>        if (data_type != NULL) {
>          /* print out the data type once for every variable! */
>          list_c *list = dynamic_cast<list_c *>(var_list);
> -        if (list == NULL) ERROR;  
> +        if (list == NULL) ERROR;
>          for (int i=0; i < list->n; i++) {
>            s4o.print("__");
>            data_type->accept(*this);
> -        }  
> +        }
>        }
>      }
> -    
> +
>    public:
> -    print_function_parameter_data_types_c(stage4out_c *s4o_ptr):
> +    print_function_parameter_data_types_c(stage4out_c *s4o_ptr):
>        generate_c_base_and_typeid_c(s4o_ptr)
>        {current_type = NULL;}
>  
> @@ -299,35 +300,35 @@
>  
>      /* already handled by iterator base class (note that generate_c_base_c inherits from iterator_c) */
>      //void *visit(var_declarations_list_c *symbol) {// iterate through list}
> -    
> +
>      /* already handled by iterator base class (note that generate_c_base_c inherits from iterator_c) */
>      //void *visit(input_declarations_c *symbol) {// iterate through list}
> -        
> +
>      /* already handled by iterator base class (note that generate_c_base_c inherits from iterator_c) */
>      //void *visit(input_declaration_list_c *symbol) {// iterate through list}
>  
>      void *visit(edge_declaration_c *symbol) {
>        {STAGE4_ERROR(symbol, symbol, "R_EDGE and F_EDGE declarations are not currently supported"); ERROR;}
> -      /*
> -      current_type = &tmp_bool;
> +      /*
> +      current_type = &tmp_bool;
>        symbol->var1_list->accept(*this);
> -      current_type = NULL;
> +      current_type = NULL;
>        */
>        return NULL;
>      }
> -    
> +
>      /* We do NOT print out EN and ENO parameters! */
>      void *visit(en_param_declaration_c *symbol) {return NULL;}
>  
>      /* already handled by iterator base class (note that generate_c_base_c inherits from iterator_c) */
> -    //void *visit(output_declarations_c *symbol) {// iterate through list}    
> -    
> +    //void *visit(output_declarations_c *symbol) {// iterate through list}
> +
>      /* already handled by iterator base class (note that generate_c_base_c inherits from iterator_c) */
>      //void *visit(var_init_decl_list_c *symbol) {// iterate through list}
>  
>      void *visit(simple_spec_init_c *symbol) {
>        /* return the data type */
> -      return symbol->simple_specification;
> +      return symbol->simple_specification;
>      }
>  
>      /* currently we do not support data types defined in the declaration itself */
> @@ -362,13 +363,13 @@
>      void *visit(eno_param_declaration_c *symbol) {return NULL;}
>  
>      /* already handled by iterator base class (note that generate_c_base_c inherits from iterator_c) */
> -    //void *visit(input_output_declarations_c *symbol) {// iterate through list}    
> +    //void *visit(input_output_declarations_c *symbol) {// iterate through list}
>  
>      /* already handled by iterator base class (note that generate_c_base_c inherits from iterator_c) */
>      //void *visit(var_declaration_list_c *symbol) {iterate through list}
>  
>      void *visit(fb_name_decl_c *symbol) {
> -      print_list(symbol->fb_name_list, spec_init_sperator_c::get_spec(symbol->fb_spec_init));
> +      print_list(symbol->fb_name_list, spec_init_sperator_c::get_spec(symbol->fb_spec_init));
>        return NULL;
>      }
>  
> @@ -382,9 +383,9 @@
>      void *visit(array_var_declaration_c *symbol) {return NULL;}
>  
>      void *visit(structured_var_declaration_c *symbol) {
> -      current_type = symbol->structure_type_name;
> +      current_type = symbol->structure_type_name;
>        symbol->var1_list->accept(*this);
> -      current_type = NULL;
> +      current_type = NULL;
>        return NULL;
>      }
>  
> @@ -402,7 +403,7 @@
>       */
>      void *visit(double_byte_string_var_declaration_c *symbol) {return NULL;}
>  };
> -    
> +
>  
>  /***********************************************************************/
>  /***********************************************************************/
> @@ -417,20 +418,20 @@
>  
>    public:
>      analyse_variable_c(void) {};
> -    
> +
>      static bool is_complex_type(symbol_c *symbol) {
>        if (NULL == symbol) ERROR;
>        if (!get_datatype_info_c::is_type_valid     (symbol->datatype)) return false;
> -      return (   get_datatype_info_c::is_structure(symbol->datatype)
> -              || get_datatype_info_c::is_array    (symbol->datatype)
> +      return (   get_datatype_info_c::is_structure(symbol->datatype)
> +              || get_datatype_info_c::is_array    (symbol->datatype)
>               );
>      }
>  
> -    
> +
>    private:
>      symbol_c *last_fb, *first_non_fb_identifier;
>  
> -  public:  
> +  public:
>      /* returns the first element (from left to right) in a structured variable that is not a FB, i.e. is either a structure or an array! */
>      /* eg:
>       *      fb1.fb2.fb3.real       returns ??????
> @@ -441,12 +442,12 @@
>        if (NULL == singleton_)       singleton_ = new analyse_variable_c();
>        if (NULL == singleton_)       ERROR;
>        if (NULL == symbol)           ERROR;
> -      
> +
>        singleton_->last_fb                 = NULL;
>        singleton_->first_non_fb_identifier = NULL;
>        return (symbol_c *)symbol->accept(*singleton_);
>      }
> -    
> +
>      /* returns true if a strcutured variable (e.g. fb1.fb2.strcut1.real) contains a structure or array */
>      /* eg:
>       *      fb1.fb2.fb3.real       returns FALSE
> @@ -456,12 +457,12 @@
>      static bool contains_complex_type(symbol_c *symbol) {
>        if (NULL == symbol) ERROR;
>        if (!get_datatype_info_c::is_type_valid(symbol->datatype)) ERROR;
> -      
> +
>        symbol_c *first_non_fb = (symbol_c *)find_first_nonfb(symbol);
>        return is_complex_type(first_non_fb->datatype);
>      }
> -    
> -    
> +
> +
>      /* returns the datatype of the variable returned by find_first_nonfb() */
>      /* eg:
>       *      fb1.fb2.fb3.real       returns ??????
> @@ -471,60 +472,60 @@
>      static search_var_instance_decl_c::vt_t first_nonfb_vardecltype(symbol_c *symbol, symbol_c *scope) {
>        if (NULL == symbol) ERROR;
>        if (!get_datatype_info_c::is_type_valid(symbol->datatype)) ERROR;
> -      
> +
>        symbol_c *first_non_fb = (symbol_c *)find_first_nonfb(symbol);
>        if (NULL != singleton_->last_fb) {
>          scope = singleton_->last_fb->datatype;
>          symbol = singleton_->first_non_fb_identifier;
>        }
> -      
> +
>        search_var_instance_decl_c search_var_instance_decl(scope);
> -      
> +
>        return search_var_instance_decl.get_vartype(symbol);
>      }
> -    
> -    
> +
> +
>      /*********************/
>      /* B 1.4 - Variables */
>      /*********************/
>      void *visit(symbolic_variable_c *symbol) {
>        if (!get_datatype_info_c::is_type_valid    (symbol->datatype)) ERROR;
>        if (!get_datatype_info_c::is_function_block(symbol->datatype)) {
> -         first_non_fb_identifier = symbol;
> +         first_non_fb_identifier = symbol;
>           return (void *)symbol;
>        }
>        last_fb = symbol;
>        return NULL;
>      }
> -    
> +
>      /*************************************/
>      /* B.1.4.2   Multi-element Variables */
>      /*************************************/
> -    
> +
>      // SYM_REF2(structured_variable_c, record_variable, field_selector)
>      void *visit(structured_variable_c *symbol) {
>        symbol_c *res = (symbol_c *)symbol->record_variable->accept(*this);
>        if (NULL != res) return res;
> -      
> +
>        if (!get_datatype_info_c::is_type_valid    (symbol->datatype)) ERROR;
>        if (!get_datatype_info_c::is_function_block(symbol->datatype)) {
> -         first_non_fb_identifier = symbol->field_selector;
> +         first_non_fb_identifier = symbol->field_selector;
>           return (void *)symbol;
>        }
>  
> -      last_fb = symbol;      
> -      return NULL;      
> +      last_fb = symbol;
> +      return NULL;
>      }
> -    
> +
>      /*  subscripted_variable '[' subscript_list ']' */
>      //SYM_REF2(array_variable_c, subscripted_variable, subscript_list)
>      void *visit(array_variable_c *symbol) {
>        void *res = symbol->subscripted_variable->accept(*this);
>        if (NULL != res) return res;
> -      return (void *)symbol;      
> +      return (void *)symbol;
>      }
>  
> -    
> +
>  };
>  
>  analyse_variable_c *analyse_variable_c::singleton_ = NULL;
> @@ -549,10 +550,10 @@
>  
>  unsigned long long calculate_time(symbol_c *symbol) {
>    if (NULL == symbol) return 0;
> -  
> +
>    interval_c *interval = dynamic_cast<interval_c *>(symbol);
>    duration_c *duration = dynamic_cast<duration_c *>(symbol);
> -  
> +
>    if ((NULL == interval) && (NULL == duration))
>      {STAGE4_ERROR(symbol, symbol, "This type of interval value is not currently supported"); ERROR;}
>  
> @@ -565,13 +566,13 @@
>  
>    if (NULL != interval) {
>      /* SYM_REF5(interval_c, days, hours, minutes, seconds, milliseconds) */
> -      unsigned long long int time_ull = 0;
> +      unsigned long long int time_ull = 0;
>        long double            time_ld  = 0;
>        /*
>        const unsigned long long int MILLISECOND = 1000000;
>        const unsigned long long int      SECOND = 1000 * MILLISECOND
>        */
> -      
> +
>        if (NULL != interval->milliseconds) {
>          if      (VALID_CVALUE( int64, interval->milliseconds) &&           GET_CVALUE( int64, interval->milliseconds) < 0) ERROR; // interval elements should always be positive!
>          if      (VALID_CVALUE( int64, interval->milliseconds)) time_ull += GET_CVALUE( int64, interval->milliseconds) * MILLISECOND;
> @@ -579,7 +580,7 @@
>          else if (VALID_CVALUE(real64, interval->milliseconds)) time_ld  += GET_CVALUE(real64, interval->milliseconds) * MILLISECOND;
>          else ERROR; // if (NULL != interval->milliseconds) is true, then it must have a valid constant value!
>        }
> -  
> +
>        if (NULL != interval->seconds     ) {
>          if      (VALID_CVALUE( int64, interval->seconds     ) &&           GET_CVALUE( int64, interval->seconds     ) < 0) ERROR; // interval elements should always be positive!
>          if      (VALID_CVALUE( int64, interval->seconds     )) time_ull += GET_CVALUE( int64, interval->seconds     ) * SECOND;
> @@ -628,13 +629,13 @@
>    private:
>      unsigned long long common_ticktime;
>      unsigned long long least_common_ticktime;
> -    
> +
>    public:
>      calculate_common_ticktime_c(void){
>        common_ticktime = 0;
>        least_common_ticktime = 0;
>      }
> -    
> +
>      unsigned long long euclide(unsigned long long a, unsigned long long b) {
>        unsigned long long c = a % b;
>        if (c == 0)
> @@ -642,7 +643,7 @@
>        else
>          return euclide(b, c);
>      }
> -    
> +
>      void update_ticktime(unsigned long long time) {
>        if (common_ticktime == 0)
>          common_ticktime = time;
> @@ -664,11 +665,12 @@
>        unsigned long long least_common_tick = least_common_ticktime / common_ticktime;
>        if (least_common_tick >> 32)
>          ERROR;
> -      return (unsigned long)(~(((unsigned long)-1) % (unsigned long)least_common_tick) + 1);
> +      //return (unsigned long)(~(((unsigned long)-1) % (unsigned long)least_common_tick) + 1);
> +      return (unsigned long)(ULONG_MAX - ((ULONG_MAX) % (unsigned long)least_common_tick));
>      }
>  
>  /*  TASK task_name task_initialization */
> -//SYM_REF2(task_configuration_c, task_name, task_initialization)  
> +//SYM_REF2(task_configuration_c, task_name, task_initialization)
>      void *visit(task_initialization_c *symbol) {
>        if (symbol->interval_data_source != NULL) {
>        unsigned long long time = calculate_time(symbol->interval_data_source);
> @@ -677,7 +679,7 @@
>        }
>        return NULL;
>      }
> -};    
> +};
>  
>  /***********************************************************************/
>  /***********************************************************************/
> @@ -694,31 +696,31 @@
>  
>    public:
>      generate_c_SFC_IL_ST_c(stage4out_c *s4o_ptr, symbol_c *name, symbol_c *scope, const char *variable_prefix = NULL);
> -    
> +
>      /********************/
>      /* 2.1.6 - Pragmas  */
>      /********************/
>      void *visit(enable_code_generation_pragma_c * symbol)   {s4o_ptr->enable_output();  return NULL;}
> -    void *visit(disable_code_generation_pragma_c * symbol)  {s4o_ptr->disable_output(); return NULL;}
> -    
> +    void *visit(disable_code_generation_pragma_c * symbol)  {s4o_ptr->disable_output(); return NULL;}
> +
>      /*********************************************/
>      /* B.1.6  Sequential function chart elements */
>      /*********************************************/
>      /*| sequential_function_chart sfc_network*/
>      void *visit(sequential_function_chart_c * symbol);
> -    
> +
>      /****************************************/
>      /* B.2 - Language IL (Instruction List) */
>      /****************************************/
> -    
> +
>      /***********************************/
>      /* B 2.1 Instructions and Operands */
>      /***********************************/
>      /*| instruction_list il_instruction */
>      void *visit(instruction_list_c *symbol);
> -    
> +
>      /* Remainder implemented in generate_c_il_c... */
> -    
> +
>      /***************************************/
>      /* B.3 - Language ST (Structured Text) */
>      /***************************************/
> @@ -726,7 +728,7 @@
>      /* B 3.1 - Expressions */
>      /***********************/
>      /* Implemented in generate_c_st_c */
> -    
> +
>      /********************/
>      /* B 3.2 Statements */
>      /********************/
> @@ -777,11 +779,11 @@
>  /***********************************************************************/
>  /***********************************************************************/
>  
> -class generate_c_pous_c {  
> +class generate_c_pous_c {
>    /* NOTE: This is NOT a visistor class!!
> -   *
> +   *
>     *       Actually, it does not even really need to be a class. It is simply a collection of similar functions!!
> -   */
> +   */
>  
>    private:
>      static void print_end_of_block_label(stage4out_c &s4o) {
> @@ -806,7 +808,7 @@
>        s4o.print(":\n");
>        s4o.indent_right();
>      }
> -  
> +
>  
>      /*************/
>      /* Functions */
> @@ -823,9 +825,9 @@
>      static void handle_function(function_declaration_c *symbol, stage4out_c &s4o, bool print_declaration) {
>        generate_c_vardecl_c          *vardecl = NULL;
>        generate_c_base_and_typeid_c   print_base(&s4o);
> -      
> +
>        TRACE("function_declaration_c");
> -    
> +
>        /* (A) Function declaration... */
>        /* (A.1) Function return type */
>        s4o.print("// FUNCTION\n");
> @@ -834,7 +836,7 @@
>        /* (A.2) Function name */
>        symbol->derived_function_name->accept(print_base);
>        s4o.print("(");
> -    
> +
>        /* (A.3) Function parameters */
>        s4o.indent_right();
>        vardecl = new generate_c_vardecl_c(&s4o,
> @@ -846,22 +848,22 @@
>                                           generate_c_vardecl_c::eno_vt);
>        vardecl->print(symbol->var_declarations_list);
>        delete vardecl;
> -      
> +
>        s4o.indent_left();
> -      
> +
>        s4o.print(")");
> -      
> +
>        /* If we only want the declaration/prototype, then return!! */
> -      if (print_declaration)
> +      if (print_declaration)
>          {s4o.print(";\n"); return;}
> -      
> +
>        /* continue generating the function definition/code... */
>        s4o.print("\n" + s4o.indent_spaces + "{\n");
> -    
> +
>        /* (B) Function local variable declaration */
>        /* (B.1) Variables declared in ST source code */
>        s4o.indent_right();
> -      
> +
>        vardecl = new generate_c_vardecl_c(&s4o,
>                      generate_c_vardecl_c::localinit_vf,
>                      generate_c_vardecl_c::output_vt   |
> @@ -870,7 +872,7 @@
>                      generate_c_vardecl_c::eno_vt);
>        vardecl->print(symbol->var_declarations_list);
>        delete vardecl;
> -    
> +
>        /* (B.2) Temporary variable for function's return value */
>        /* It will have the same name as the function itself! */
>        /* NOTE: matiec supports a non-standard syntax, in which functions do not return a value
> @@ -878,7 +880,7 @@
>         *       e.g.:   FUNCTION foo: VOID
>         *                ...
>         *               END_FUNCTION
> -       *      
> +       *
>         *       These functions cannot return any value, so they do not need a variable to
>         *       store the return value.
>         *       Note that any attemot to sto a value in the implicit variable
> @@ -886,7 +888,7 @@
>         *                ...
>         *                 foo := 42;
>         *               END_FUNCTION
> -       *       will always return a datatype incompatilibiyt error in stage 3 of matiec,
> +       *       will always return a datatype incompatilibiyt error in stage 3 of matiec,
>         *       so it is safe for stage 4 to assume that this return variable will never be needed
>         *       if the function's return type is VOID.
>         */
> @@ -925,8 +927,8 @@
>          }
>        }
>        s4o.print(";\n\n");
> -      
> -      
> +
> +
>        // Only generate the code that controls the execution of the function's body if the
>        // function contains a declaration of both the EN and ENO variables
>        search_var_instance_decl_c search_var(symbol);
> @@ -950,13 +952,13 @@
>          s4o.indent_left();
>          s4o.print(s4o.indent_spaces + "}\n");
>        }
> -    
> +
>        /* (C) Function body */
>        generate_c_SFC_IL_ST_c generate_c_code(&s4o, symbol->derived_function_name, symbol);
>        symbol->function_body->accept(generate_c_code);
> -      
> +
>        print_end_of_block_label(s4o);
> -      
> +
>        vardecl = new generate_c_vardecl_c(&s4o,
>                      generate_c_vardecl_c::foutputassign_vf,
>                      generate_c_vardecl_c::output_vt   |
> @@ -964,7 +966,7 @@
>                      generate_c_vardecl_c::eno_vt);
>        vardecl->print(symbol->var_declarations_list);
>        delete vardecl;
> -      
> +
>        if (!get_datatype_info_c::is_VOID(symbol->type_name->datatype)) { // only print 'return <fname>' if return datatype is not VOID
>          s4o.print(s4o.indent_spaces + "return ");
>          symbol->derived_function_name->accept(print_base);
> @@ -973,11 +975,11 @@
>  
>        s4o.indent_left();
>        s4o.print(s4o.indent_spaces + "}\n\n\n");
> -    
> +
>        return;
>      }
> -    
> -    
> +
> +
>      /*******************/
>      /* Function Blocks */
>      /*******************/
> @@ -995,7 +997,7 @@
>        generate_c_sfcdecl_c          *sfcdecl;
>        generate_c_base_and_typeid_c   print_base(&s4o);
>        TRACE("function_block_declaration_c");
> -    
> +
>        /* (A) Function Block data structure declaration... */
>        if (print_declaration) {
>          /* (A.1) Data structure declaration */
> @@ -1028,34 +1030,34 @@
>                                             generate_c_vardecl_c::external_vt);
>          vardecl->print(symbol->var_declarations);
>          delete vardecl;
> -        
> +
>          /* (A.4) Generate private internal variables for SFC */
>          sfcdecl = new generate_c_sfcdecl_c(&s4o, symbol);
>          sfcdecl->generate(symbol->fblock_body, generate_c_sfcdecl_c::sfcdecl_sd);
>          delete sfcdecl;
>          s4o.print("\n");
> -      
> +
>          /* (A.5) Function Block data structure type name. */
>          s4o.indent_left();
>          s4o.print("} ");
>          symbol->fblock_name->accept(print_base);
>          s4o.print(";\n\n");
>        }
> -      
> +
>        if (!print_declaration) {
>          /* (A.6) Function Block inline function declaration for function invocation */
>          generate_c_inlinefcall_c *inlinedecl = new generate_c_inlinefcall_c(&s4o, symbol->fblock_name, symbol, FB_FUNCTION_PARAM"->");
>          symbol->fblock_body->accept(*inlinedecl);
>          delete inlinedecl;
>        }
> -      
> +
>        /* (B) Constructor */
>        /* (B.1) Constructor name... */
>        s4o.print(s4o.indent_spaces + "void ");
>        symbol->fblock_name->accept(print_base);
>        s4o.print(FB_INIT_SUFFIX);
>        s4o.print("(");
> -    
> +
>        /* first and only parameter is a pointer to the data */
>        symbol->fblock_name->accept(print_base);
>        s4o.print(" *");
> @@ -1067,7 +1069,7 @@
>        } else {
>          s4o.print(" {\n");
>          s4o.indent_right();
> -      
> +
>          /* (B.2) Member initializations... */
>          s4o.print(s4o.indent_spaces);
>          vardecl = new generate_c_vardecl_c(&s4o,
> @@ -1083,23 +1085,23 @@
>          vardecl->print(symbol->var_declarations, NULL, FB_FUNCTION_PARAM"->");
>          delete vardecl;
>          s4o.print("\n");
> -            
> +
>          /* (B.3) Generate private internal variables for SFC */
>          sfcdecl = new generate_c_sfcdecl_c(&s4o, symbol, FB_FUNCTION_PARAM"->");
>          sfcdecl->generate(symbol->fblock_body, generate_c_sfcdecl_c::sfcinit_sd);
> -      
> +
>          s4o.indent_left();
>          s4o.print(s4o.indent_spaces + "}\n\n");
>  
>          /* (C) Function with FB body */
>          /* (C.1) Step definitions */
>          sfcdecl->generate(symbol->fblock_body, generate_c_sfcdecl_c::stepdef_sd);
> -      
> +
>          /* (C.2) Action definitions */
>          sfcdecl->generate(symbol->fblock_body, generate_c_sfcdecl_c::actiondef_sd);
>          delete sfcdecl;
>        }
> -      
> +
>        /* (C.3) Function declaration */
>        s4o.print("// Code part\n");
>        /* function interface */
> @@ -1152,7 +1154,7 @@
>            s4o.indent_left();
>            s4o.print(s4o.indent_spaces + "}\n");
>          }
> -      
> +
>          /* (C.4) Initialize TEMP variables */
>          /* function body */
>          s4o.print(s4o.indent_spaces + "// Initialise TEMP variables\n");
> @@ -1162,7 +1164,7 @@
>          vardecl->print(symbol->var_declarations, NULL,  FB_FUNCTION_PARAM"->");
>          delete vardecl;
>          s4o.print("\n");
> -      
> +
>          /* (C.5) Function code */
>          generate_c_SFC_IL_ST_c generate_c_code(&s4o, symbol->fblock_name, symbol, FB_FUNCTION_PARAM"->");
>          symbol->fblock_body->accept(generate_c_code);
> @@ -1173,22 +1175,22 @@
>          symbol->fblock_name->accept(print_base);
>          s4o.print(FB_FUNCTION_SUFFIX);
>          s4o.print(s4o.indent_spaces + "() \n\n");
> -      
> +
>          /* (C.6) Step undefinitions */
>          sfcdecl = new generate_c_sfcdecl_c(&s4o, symbol, FB_FUNCTION_PARAM"->");
>          sfcdecl->generate(symbol->fblock_body, generate_c_sfcdecl_c::stepundef_sd);
> -      
> +
>          /* (C.7) Action undefinitions */
>          sfcdecl->generate(symbol->fblock_body, generate_c_sfcdecl_c::actionundef_sd);
>          delete sfcdecl;
> -      
> +
>          s4o.indent_left();
>          s4o.print("\n\n\n\n");
>        }
>        return;
>      }
> -    
> -    
> +
> +
>      /************/
>      /* Programs */
>      /************/
> @@ -1206,16 +1208,16 @@
>        generate_c_sfcdecl_c          *sfcdecl;
>        generate_c_base_and_typeid_c   print_base(&s4o);
>        TRACE("program_declaration_c");
> -    
> +
>        /* (A) Program data structure declaration... */
> -      if (print_declaration) {      
> +      if (print_declaration) {
>          /* (A.1) Data structure declaration */
>          s4o.print("// PROGRAM ");
>          symbol->program_type_name->accept(print_base);
>          s4o.print("\n// Data part\n");
>          s4o.print("typedef struct {\n");
>          s4o.indent_right();
> -      
> +
>          /* (A.2) Public variables: i.e. the program parameters... */
>          s4o.print(s4o.indent_spaces + "// PROGRAM Interface - IN, OUT, IN_OUT variables\n");
>          vardecl = new generate_c_vardecl_c(&s4o,
> @@ -1226,7 +1228,7 @@
>          vardecl->print(symbol->var_declarations);
>          delete vardecl;
>          s4o.print("\n");
> -  
> +
>          /* (A.3) Private internal variables */
>          s4o.print(s4o.indent_spaces + "// PROGRAM private variables - TEMP, private and located variables\n");
>          vardecl = new generate_c_vardecl_c(&s4o,
> @@ -1237,34 +1239,34 @@
>                        generate_c_vardecl_c::external_vt);
>          vardecl->print(symbol->var_declarations);
>          delete vardecl;
> -      
> +
>          /* (A.4) Generate private internal variables for SFC */
>          sfcdecl = new generate_c_sfcdecl_c(&s4o, symbol);
>          sfcdecl->generate(symbol->function_block_body, generate_c_sfcdecl_c::sfcdecl_sd);
>          delete sfcdecl;
>          s4o.print("\n");
> -        
> +
>          /* (A.5) Program data structure type name. */
>          s4o.indent_left();
>          s4o.print("} ");
>          symbol->program_type_name->accept(print_base);
>          s4o.print(";\n\n");
>        }
> -      
> -      if (!print_declaration) {      
> +
> +      if (!print_declaration) {
>          /* (A.6) Function Block inline function declaration for function invocation */
>          generate_c_inlinefcall_c *inlinedecl = new generate_c_inlinefcall_c(&s4o, symbol->program_type_name, symbol, FB_FUNCTION_PARAM"->");
>          symbol->function_block_body->accept(*inlinedecl);
>          delete inlinedecl;
>        }
> -    
> +
>        /* (B) Constructor */
>        /* (B.1) Constructor name... */
>        s4o.print(s4o.indent_spaces + "void ");
>        symbol->program_type_name->accept(print_base);
>        s4o.print(FB_INIT_SUFFIX);
>        s4o.print("(");
> -    
> +
>        /* first and only parameter is a pointer to the data */
>        symbol->program_type_name->accept(print_base);
>        s4o.print(" *");
> @@ -1276,7 +1278,7 @@
>        } else {
>          s4o.print(" {\n");
>          s4o.indent_right();
> -      
> +
>          /* (B.2) Member initializations... */
>          s4o.print(s4o.indent_spaces);
>          vardecl = new generate_c_vardecl_c(&s4o,
> @@ -1290,27 +1292,27 @@
>          vardecl->print(symbol->var_declarations, NULL,  FB_FUNCTION_PARAM"->");
>          delete vardecl;
>          s4o.print("\n");
> -      
> +
>          /* (B.3) Generate private internal variables for SFC */
>          sfcdecl = new generate_c_sfcdecl_c(&s4o, symbol, FB_FUNCTION_PARAM"->");
>          sfcdecl->generate(symbol->function_block_body, generate_c_sfcdecl_c::sfcinit_sd);
>          delete sfcdecl;
> -      
> +
>          s4o.indent_left();
>          s4o.print(s4o.indent_spaces + "}\n\n");
>        }
> -    
> -      if (!print_declaration) {    
> +
> +      if (!print_declaration) {
>          /* (C) Function with PROGRAM body */
>          /* (C.1) Step definitions */
>          sfcdecl = new generate_c_sfcdecl_c(&s4o, symbol, FB_FUNCTION_PARAM"->");
>          sfcdecl->generate(symbol->function_block_body, generate_c_sfcdecl_c::stepdef_sd);
> -      
> +
>          /* (C.2) Action definitions */
>          sfcdecl->generate(symbol->function_block_body, generate_c_sfcdecl_c::actiondef_sd);
>          delete sfcdecl;
>        }
> -      
> +
>        /* (C.3) Function declaration */
>        s4o.print("// Code part\n");
>        /* function interface */
> @@ -1329,7 +1331,7 @@
>        } else {
>          s4o.print(" {\n");
>          s4o.indent_right();
> -          
> +
>          /* (C.4) Initialize TEMP variables */
>          /* function body */
>          s4o.print(s4o.indent_spaces + "// Initialise TEMP variables\n");
> @@ -1339,7 +1341,7 @@
>          vardecl->print(symbol->var_declarations, NULL,  FB_FUNCTION_PARAM"->");
>          delete vardecl;
>          s4o.print("\n");
> -      
> +
>          /* (C.5) Function code */
>          generate_c_SFC_IL_ST_c generate_c_code(&s4o, symbol->program_type_name, symbol, FB_FUNCTION_PARAM"->");
>          symbol->function_block_body->accept(generate_c_code);
> @@ -1350,23 +1352,23 @@
>          symbol->program_type_name->accept(print_base);
>          s4o.print(FB_FUNCTION_SUFFIX);
>          s4o.print(s4o.indent_spaces + "() \n\n");
> -      
> +
>          /* (C.6) Step undefinitions */
>          sfcdecl = new generate_c_sfcdecl_c(&s4o, symbol, FB_FUNCTION_PARAM"->");
>          sfcdecl->generate(symbol->function_block_body, generate_c_sfcdecl_c::stepundef_sd);
> -        
> +
>          /* (C.7) Action undefinitions */
> -        sfcdecl->generate(symbol->function_block_body, generate_c_sfcdecl_c::actionundef_sd);
> +        sfcdecl->generate(symbol->function_block_body, generate_c_sfcdecl_c::actionundef_sd);
>          delete sfcdecl;
> -      
> +
>          s4o.indent_left();
>          s4o.print("\n\n\n\n");
> -      }  
> +      }
>        return;
>      }
>  }; /* generate_c_pous_c */
>  
> -    
> +
>  /***********************************************************************/
>  /***********************************************************************/
>  /***********************************************************************/
> @@ -1379,7 +1381,7 @@
>  class generate_c_config_c: public generate_c_base_and_typeid_c {
>      private:
>      stage4out_c &s4o_incl;
> -    
> +
>      public:
>      generate_c_config_c(stage4out_c *s4o_ptr, stage4out_c *s4o_incl_ptr)
>        : generate_c_base_and_typeid_c(s4o_ptr), s4o_incl(*s4o_incl_ptr) {
> @@ -1396,7 +1398,7 @@
>  
>      declaretype_t wanted_declaretype;
>  
> -    
> +
>  public:
>  /********************/
>  /* 2.1.6 - Pragmas  */
> @@ -1409,11 +1411,11 @@
>  
>  void *visit(disable_code_generation_pragma_c * symbol)  {
>      s4o.disable_output();
> -    s4o_incl.disable_output();    
> +    s4o_incl.disable_output();
>      return NULL;
>  }
> -    
> -    
> +
> +
>  /********************************/
>  /* B 1.7 Configuration elements */
>  /********************************/
> @@ -1430,13 +1432,13 @@
>  */
>  void *visit(configuration_declaration_c *symbol) {
>    generate_c_vardecl_c *vardecl;
> -  
> +
>    /* Insert the header... */
>    s4o.print("/*******************************************/\n");
>    s4o.print("/*     FILE GENERATED BY iec2c             */\n");
>    s4o.print("/* Editing this file is not recommended... */\n");
>    s4o.print("/*******************************************/\n\n");
> -  
> +
>    if (runtime_options.disable_implicit_en_eno) {
>      // If we are not generating the EN and ENO parameters for functions and FB,
>      //   then make sure we use the standard library version compiled without these parameters too!
> @@ -1444,9 +1446,9 @@
>      s4o.print("#define DISABLE_EN_ENO_PARAMETERS\n");
>      s4o.print("#endif\n");
>    }
> -  
> +
>    s4o.print("#include \"iec_std_lib.h\"\n\n");
> -  s4o.print("#include \"accessor.h\"\n\n");
> +  s4o.print("#include \"accessor.h\"\n\n");
>    s4o.print("#include \"POUS.h\"\n\n");
>  
>    /* (A) configuration declaration... */
> @@ -1454,7 +1456,7 @@
>    s4o.print("// CONFIGURATION ");
>    symbol->configuration_name->accept(*this);
>    s4o.print("\n");
> -  
> +
>    /* (A.2) Global variables */
>    vardecl = new generate_c_vardecl_c(&s4o,
>                                       generate_c_vardecl_c::local_vf,
> @@ -1478,7 +1480,7 @@
>    wanted_declaretype = initprotos_dt;
>    symbol->resource_declarations->accept(*this);
>    s4o.print("\n");
> -  
> +
>    /* (B.2) Initialisation function name... */
>    s4o.print(s4o.indent_spaces + "void config");
>    s4o.print(FB_INIT_SUFFIX);
> @@ -1488,7 +1490,7 @@
>    s4o.print("BOOL retain;\n");
>    s4o.print(s4o.indent_spaces);
>    s4o.print("retain = 0;\n");
> -  
> +
>    /* (B.3) Global variables initializations... */
>    s4o.print(s4o.indent_spaces);
>    vardecl = new generate_c_vardecl_c(&s4o,
> @@ -1498,11 +1500,11 @@
>    vardecl->print(symbol);
>    delete vardecl;
>    s4o.print("\n");
> -  
> +
>    /* (B.3) Resources initializations... */
>    wanted_declaretype = initdeclare_dt;
>    symbol->resource_declarations->accept(*this);
> -  
> +
>    s4o.indent_left();
>    s4o.print(s4o.indent_spaces + "}\n\n");
>  
> @@ -1637,7 +1639,7 @@
>      declaretype_t wanted_declaretype;
>  
>      unsigned long long common_ticktime;
> -    
> +
>      const char *current_program_name;
>  
>      typedef enum {
> @@ -1688,8 +1690,8 @@
>      /* 2.1.6 - Pragmas  */
>      /********************/
>      void *visit(enable_code_generation_pragma_c * symbol)   {s4o.enable_output();  return NULL;}
> -    void *visit(disable_code_generation_pragma_c * symbol)  {s4o.disable_output(); return NULL;}
> -    
> +    void *visit(disable_code_generation_pragma_c * symbol)  {s4o.disable_output(); return NULL;}
> +
>  
>      /******************************************/
>      /* B 1.4.3 - Declaration & Initialisation */
> @@ -1728,9 +1730,9 @@
>      void *visit(resource_declaration_c *symbol) {
>        current_resource_name = symbol->resource_name;
>        current_global_vars = symbol->global_var_declarations;
> -      
> +
>        symbol->resource_declaration->accept(*this);
> -      
> +
>        current_resource_name = NULL;
>        current_global_vars = NULL;
>        return NULL;
> @@ -1743,13 +1745,13 @@
>        if (single_resource)
>          current_resource_name = new identifier_c("RESOURCE");
>        generate_c_vardecl_c *vardecl;
> -      
> +
>        /* Insert the header... */
>        s4o.print("/*******************************************/\n");
>        s4o.print("/*     FILE GENERATED BY iec2c             */\n");
>        s4o.print("/* Editing this file is not recommended... */\n");
>        s4o.print("/*******************************************/\n\n");
> -  
> +
>        if (runtime_options.disable_implicit_en_eno) {
>          // If we are not generating the EN and ENO parameters for functions and FB,
>          //   then make sure we use the standard library version compiled without these parameters too!
> @@ -1757,15 +1759,15 @@
>          s4o.print("#define DISABLE_EN_ENO_PARAMETERS\n");
>          s4o.print("#endif\n");
>        }
> -      
> +
>        s4o.print("#include \"iec_std_lib.h\"\n\n");
> -      
> +
>        /* (A) resource declaration... */
>        /* (A.1) resource name in comment */
>        s4o.print("// RESOURCE ");
>        current_resource_name->accept(*this);
>        s4o.print("\n\n");
> -      
> +
>        s4o.print("extern unsigned long long common_ticktime__;\n\n");
>  
>        s4o.print("#include \"accessor.h\"\n");
> @@ -1786,20 +1788,20 @@
>          delete vardecl;
>          s4o.print("\n");
>        }
> -      
> +
>        /* (A.3) POUs inclusion */
>        s4o.print("#include \"POUS.c\"\n\n");
> -      
> +
>        wanted_declaretype = declare_dt;
> -      
> +
>        /* (A.4) Resource programs declaration... */
>        symbol->task_configuration_list->accept(*this);
> -      
> +
>        /* (A.5) Resource programs declaration... */
>        symbol->program_configuration_list->accept(*this);
> -      
> +
>        s4o.print("\n");
> -      
> +
>        /* (B) resource initialisation function... */
>        /* (B.1) initialisation function name... */
>        s4o.print("void ");
> @@ -1811,7 +1813,7 @@
>        s4o.print("BOOL retain;\n");
>        s4o.print(s4o.indent_spaces);
>        s4o.print("retain = 0;\n");
> -      
> +
>        /* (B.2) Global variables initialisations... */
>        if (current_global_vars != NULL) {
>          s4o.print(s4o.indent_spaces);
> @@ -1823,18 +1825,18 @@
>          delete vardecl;
>        }
>        s4o.print("\n");
> -      
> +
>        wanted_declaretype = init_dt;
> -      
> +
>        /* (B.3) Tasks initialisations... */
>        symbol->task_configuration_list->accept(*this);
> -      
> +
>        /* (B.4) Resource programs initialisations... */
>        symbol->program_configuration_list->accept(*this);
> -      
> +
>        s4o.indent_left();
>        s4o.print("}\n\n");
> -      
> +
>        /* (C) Resource run function... */
>        /* (C.1) Run function name... */
>        s4o.print("void ");
> @@ -1842,25 +1844,25 @@
>        s4o.print(FB_RUN_SUFFIX);
>        s4o.print("(unsigned long tick) {\n");
>        s4o.indent_right();
> -      
> +
>        wanted_declaretype = run_dt;
> -      
> +
>        /* (C.2) Task management... */
>        symbol->task_configuration_list->accept(*this);
> -      
> +
>        /* (C.3) Program run declaration... */
>        symbol->program_configuration_list->accept(*this);
> -      
> +
>        s4o.indent_left();
>        s4o.print("}\n\n");
> -      
> +
>        if (single_resource) {
>          delete current_resource_name;
>          current_resource_name = NULL;
>        }
>        return NULL;
>      }
> -    
> +
>  /*  PROGRAM [RETAIN | NON_RETAIN] program_name [WITH task_name] ':' program_type_name ['(' prog_conf_elements ')'] */
>  //SYM_REF6(program_configuration_c, retain_option, program_name, task_name, program_type_name, prog_conf_elements, unused)
>      void *visit(program_configuration_c *symbol) {
> @@ -1891,7 +1893,7 @@
>            print_retain();
>            s4o.print(");\n");
>            break;
> -        case run_dt:
> +        case run_dt:
>            { identifier_c *tmp_id = dynamic_cast<identifier_c*>(symbol->program_name);
>              if (NULL == tmp_id) ERROR;
>              current_program_name = tmp_id->value;
> @@ -1901,24 +1903,24 @@
>              s4o.print("if (");
>              symbol->task_name->accept(*this);
>              s4o.print(") {\n");
> -            s4o.indent_right();
> +            s4o.indent_right();
>            }
> -        
> +
>            wanted_assigntype = assign_at;
>            if (symbol->prog_conf_elements != NULL)
>              symbol->prog_conf_elements->accept(*this);
> -          
> +
>            s4o.print(s4o.indent_spaces);
>            symbol->program_type_name->accept(*this);
>            s4o.print(FB_FUNCTION_SUFFIX);
>            s4o.print("(&");
>            symbol->program_name->accept(*this);
>            s4o.print(");\n");
> -          
> +
>            wanted_assigntype = send_at;
>            if (symbol->prog_conf_elements != NULL)
>              symbol->prog_conf_elements->accept(*this);
> -          
> +
>            if (symbol->task_name != NULL) {
>              s4o.indent_left();
>              s4o.print(s4o.indent_spaces + "}\n");
> @@ -1929,7 +1931,7 @@
>        }
>        return NULL;
>      }
> -    
> +
>  /*  TASK task_name task_initialization */
>  //SYM_REF2(task_configuration_c, task_name, task_initialization)
>      void *visit(task_configuration_c *symbol) {
> @@ -1956,7 +1958,7 @@
>        current_task_name = NULL;
>        return NULL;
>      }
> -    
> +
>  /*  '(' [SINGLE ASSIGN data_source ','] [INTERVAL ASSIGN data_source ','] PRIORITY ASSIGN integer ')' */
>  //SYM_REF4(task_initialization_c, single_data_source, interval_data_source, priority_data_source, unused)
>      void *visit(task_initialization_c *symbol) {
> @@ -2031,7 +2033,7 @@
>                else
>                  s4o.print("1");
>              }
> -            else
> +            else
>                s4o.print("1");
>            }
>            s4o.print(";\n");
> @@ -2059,7 +2061,7 @@
>          }
>          else
>            vartype = search_resource_instance->get_vartype(current_var_reference);
> -        
> +
>          s4o.print(s4o.indent_spaces + "{extern ");
>          var_decl->accept(*this);
>          s4o.print(" *");
> @@ -2094,7 +2096,7 @@
>          }
>          else
>            vartype = search_resource_instance->get_vartype(current_var_reference);
> -        
> +
>          s4o.print(s4o.indent_spaces + "{extern ");
>          var_decl->accept(*this);
>          s4o.print(" *");
> @@ -2131,7 +2133,7 @@
>  #define BACKUP_   "_backup__"
>  
>  /* class to generate the forward declaration of the XXXX_backup() and XXXX_restore()
> - * functions that will later (in the generated C source code) be defined
> + * functions that will later (in the generated C source code) be defined
>   * to backup/restore the global state of each RESOURCE in the source code being compiled.
>   * The XXXX is actually the resource name!
>   */
> @@ -2139,27 +2141,27 @@
>    public:
>      generate_c_backup_resource_decl_c(stage4out_c *s4o_ptr)
>        : generate_c_base_and_typeid_c(s4o_ptr) {};
> -      
> +
>      void *visit(resource_declaration_c *symbol) {
>        s4o.print(s4o.indent_spaces);
>        s4o.print("void ");
>        symbol->resource_name->accept(*this);
> -      s4o.print("_backup__" "(void **buffer, int *maxsize);\n");      
> +      s4o.print("_backup__" "(void **buffer, int *maxsize);\n");
>        s4o.print(s4o.indent_spaces);
>        s4o.print("void ");
>        symbol->resource_name->accept(*this);
> -      s4o.print("_restore__" "(void **buffer, int *maxsize);\n");      
> +      s4o.print("_restore__" "(void **buffer, int *maxsize);\n");
>        return NULL;
>      }
> -    
> -    
> +
> +
>      void *visit(single_resource_declaration_c *symbol) {
>        /* __Must__ not insert any code! */
>        /* sinlge resources will not create a specific function for the resource */
>        /* backup and restore opertions will be inserted together with the configuration! */
>        return NULL;
>      }
> -    
> +
>  };
>  
>  
> @@ -2174,7 +2176,7 @@
>    s4o.indent_right();
>    // Don't save/restore the __CURRENT_TIME variable, as 'plc controller' has easy access to it
>    // and can therefore do the save/restore by itself.
> -//s4o.print(s4o.indent_spaces);
> +//s4o.print(s4o.indent_spaces);
>  //s4o.print(operation);
>  //s4o.print("(&__CURRENT_TIME, sizeof(__CURRENT_TIME), buffer, maxsize);\n");
>    s4o.print(s4o.indent_spaces);
> @@ -2202,7 +2204,7 @@
>    s4o.print(s4o.indent_spaces); s4o.print("#undef " DECLARE_GLOBAL_LOCATION "\n");
>    s4o.print(s4o.indent_spaces); s4o.print("#undef " DECLARE_GLOBAL_LOCATED  "\n");
>    s4o.indent_left();
> -  s4o.print("}\n");      
> +  s4o.print("}\n");
>  }
>  
>  
> @@ -2214,29 +2216,29 @@
>   * function generated for the configuration in which the resource is embedded
>   */
>  class generate_c_backup_resource_c: public generate_c_base_and_typeid_c {
> -  public:    
> +  public:
>      const char *operation;
> -    
> +
>      generate_c_backup_resource_c(stage4out_c *s4o_ptr)
>        : generate_c_base_and_typeid_c(s4o_ptr) {
>        operation = NULL;
>      };
>  
> -  
> +
>      virtual ~generate_c_backup_resource_c(void) {}
>  
> -    
> +
>  private:
>      void print_forward_declarations(void) {
>        s4o.print("\n\n\n");
> -  
> +
>        s4o.print("void ");
>        s4o.print("_backup__");
>        s4o.print("(void *varptr, int varsize, void **buffer, int *maxsize);\n");
>        s4o.print("void ");
>        s4o.print("_restore__");
>        s4o.print("(void *varptr, int varsize, void **buffer, int *maxsize);\n");
> -  
> +
>        s4o.print("\n\n\n");
>        s4o.print("#undef " DECLARE_GLOBAL          "\n");
>        s4o.print("#undef " DECLARE_GLOBAL_FB       "\n");
> @@ -2250,8 +2252,8 @@
>      /********************/
>      void *visit(enable_code_generation_pragma_c * symbol)   {s4o.enable_output(); return NULL;}
>      void *visit(disable_code_generation_pragma_c * symbol)  {s4o.disable_output();return NULL;}
> -        
> -        
> +
> +
>      /********************************/
>      /* B 1.7 Configuration elements */
>      /********************************/
> @@ -2259,24 +2261,24 @@
>        char *resource_name = strdup(symbol->resource_name->token->value);
>        /* convert to upper case */
>        for (char *c = resource_name; *c != '\0'; *c = toupper(*c), c++);
> -      
> +
>        generate_c_vardecl_c vardecl = generate_c_vardecl_c(&s4o,
>                                           generate_c_vardecl_c::local_vf,
>                                           generate_c_vardecl_c::global_vt,
>                                           symbol->resource_name);
> -      
> +
>        print_forward_declarations();
> -      
> +
>        print_backup_restore_function_beg(s4o, resource_name, "_backup__");
> -      if (symbol->global_var_declarations != NULL)  
> +      if (symbol->global_var_declarations != NULL)
>          vardecl.print(symbol->global_var_declarations);
>        if (symbol->resource_declaration != NULL) {
>          operation = "_backup__";
>          symbol->resource_declaration->accept(*this);  // will call visit(single_resource_declaration_c *)
>          operation = NULL;
>        }
> -      print_backup_restore_function_end(s4o);      
> -      
> +      print_backup_restore_function_end(s4o);
> +
>        print_backup_restore_function_beg(s4o, resource_name, "_restore__");
>        if (symbol->global_var_declarations != NULL)
>          vardecl.print(symbol->global_var_declarations);
> @@ -2285,18 +2287,18 @@
>          symbol->resource_declaration->accept(*this);  // will call visit(single_resource_declaration_c *)
>          operation = NULL;
>        }
> -      print_backup_restore_function_end(s4o);      
> +      print_backup_restore_function_end(s4o);
>  
>        return NULL;
>      }
> -    
> +
>      void *visit(single_resource_declaration_c *symbol) {
>        /* Must store the declared/instatiated PROGRAMS */
>        if (symbol->program_configuration_list != NULL)
>          symbol->program_configuration_list->accept(*this);
>        return NULL;
>      }
> -    
> +
>      /*  PROGRAM [RETAIN | NON_RETAIN] program_name [WITH task_name] ':' program_type_name ['(' prog_conf_elements ')'] */
>      // SYM_REF5(program_configuration_c, retain_option, program_name, task_name, program_type_name, prog_conf_elements)
>      void *visit(program_configuration_c *symbol) {
> @@ -2304,7 +2306,7 @@
>        // _xxxxxx__(&program_name, sizeof(program_name), buffer, maxsize);
>        s4o.print(s4o.indent_spaces);
>        s4o.print(operation); // call _restore__() or _backup__()
> -      s4o.print("(&");
> +      s4o.print("(&");
>        symbol->program_name->accept(*this);
>        s4o.print(", sizeof(");
>        symbol->program_name->accept(*this);
> @@ -2321,20 +2323,20 @@
>   * configuration, and call the backup/restore functions of each embedded resource to do
>   * the same for the global variables declared inside each resource.
>   *
> - *   The matiec compiler will now generate two additional functions which
> + *   The matiec compiler will now generate two additional functions which
>   *   will backup and restore the PLC internal state to a void *buffer.
>   *       config_backup__(void **buffer, int *maxsize)
>   *       config_restore__(void **buffer, int *maxsize)
>   *
> - *   Both functions will backup/restore the internal state from the memory
> + *   Both functions will backup/restore the internal state from the memory
>   *   pointed to by *buffer, up to a maximum of *maxsize bytes.
> - *   Both functions will return with buffer pointing to the first unused
> - *   byte in the buffer, and maxsize with the number of remaining bytes. If
> - *   the buffer is not sufficient to store all the internal state, maxsize
> - *   will return with a negative number, equal to the number of missing
> + *   Both functions will return with buffer pointing to the first unused
> + *   byte in the buffer, and maxsize with the number of remaining bytes. If
> + *   the buffer is not sufficient to store all the internal state, maxsize
> + *   will return with a negative number, equal to the number of missing
>   *   bytes.
>   *
> - *   In other words, to know the exact size of the buffer required to store
> + *   In other words, to know the exact size of the buffer required to store
>   *   the PLC internal state, malloc() that memory, and do the backup:
>   *          int maxsize = 0;
>   *          config_backup__(NULL, &maxsize);
> @@ -2355,15 +2357,15 @@
>  
>      virtual ~generate_c_backup_config_c(void) {}
>  
> -    
> +
>    public:
>      /********************/
>      /* 2.1.6 - Pragmas  */
>      /********************/
>      void *visit(enable_code_generation_pragma_c * symbol)   {s4o.enable_output(); return NULL;}
>      void *visit(disable_code_generation_pragma_c * symbol)  {s4o.disable_output();return NULL;}
> -        
> -        
> +
> +
>      /********************************/
>      /* B 1.7 Configuration elements */
>      /********************************/
> @@ -2371,24 +2373,24 @@
>      SYM_REF6(configuration_declaration_c, configuration_name, global_var_declarations, resource_declarations, access_declarations, instance_specific_initializations, unused)
>      */
>      void *visit(configuration_declaration_c *symbol) {
> -      
> +
>        s4o.print("\n\n\n");
> -      
> +
>        s4o.print("void ");
>        s4o.print("_backup__");
>        s4o.print("(void *varptr, int varsize, void **buffer, int *maxsize) {\n");
>        s4o.print("  if (varsize <= *maxsize) {memmove(*buffer, varptr, varsize); *buffer += varsize;}\n");
>        s4o.print("  *maxsize -= varsize;\n");
>        s4o.print("}\n");
> -      
> +
>        s4o.print("void ");
>        s4o.print("_restore__");
>        s4o.print("(void *varptr, int varsize, void **buffer, int *maxsize) {\n");
>        s4o.print("  if (varsize <= *maxsize) {memmove(varptr, *buffer, varsize); *buffer += varsize;}\n");
>        s4o.print("  *maxsize -= varsize;\n");
>        s4o.print("}\n");
> -      
> -      
> +
> +
>        generate_c_vardecl_c vardecl = generate_c_vardecl_c(&s4o,
>                                           generate_c_vardecl_c::local_vf,
>                                           generate_c_vardecl_c::global_vt,
> @@ -2399,37 +2401,37 @@
>        s4o.print("#undef " DECLARE_GLOBAL_FB       "\n");
>        s4o.print("#undef " DECLARE_GLOBAL_LOCATION "\n");
>        s4o.print("#undef " DECLARE_GLOBAL_LOCATED  "\n");
> -      
> +
>        generate_c_backup_resource_decl_c declare_functions = generate_c_backup_resource_decl_c(&s4o);
>        symbol->resource_declarations->accept(declare_functions);
> -      
> +
>        print_backup_restore_function_beg(s4o, "config", "_backup__");
>        vardecl.print(symbol);
>        s4o.print("\n");
>        func_to_call = "_backup__";
>        symbol->resource_declarations->accept(*this);  // will call resource_declaration_list_c or single_resource_declaration_c
>        func_to_call = NULL;
> -      print_backup_restore_function_end(s4o);      
> -    
> +      print_backup_restore_function_end(s4o);
> +
>        print_backup_restore_function_beg(s4o, "config", "_restore__");
>        vardecl.print(symbol);
>        s4o.print("\n");
>        func_to_call = "_restore__";
>        symbol->resource_declarations->accept(*this);  // will call resource_declaration_list_c or single_resource_declaration_c
>        func_to_call = NULL;
> -      print_backup_restore_function_end(s4o);      
> -      
> +      print_backup_restore_function_end(s4o);
> +
>        return NULL;
>      }
> -    
> +
>      void *visit(resource_declaration_c *symbol) {
>        s4o.print(s4o.indent_spaces);
>        symbol->resource_name->accept(*this);
>        s4o.print(func_to_call);
> -      s4o.print("(buffer, maxsize);\n");      
> +      s4o.print("(buffer, maxsize);\n");
>        return NULL;
>      }
> -    
> +
>      void *visit(single_resource_declaration_c *symbol) {
>        /* If the configuration does not have any resources, we must store/restore the declared program instances
>         * inside the backup() restore() functions created for the configuration.
> @@ -2460,22 +2462,22 @@
>      stage4out_c             pous_incl_s4o;
>      stage4out_c     located_variables_s4o;
>      stage4out_c             variables_s4o;
> -    
> +
>      generate_c_typedecl_c          generate_c_typedecl;
>      generate_c_implicit_typedecl_c generate_c_implicit_typedecl;
>      generate_c_pous_c              generate_c_pous;
> -    
> +
>      symbol_c   *current_configuration;
>  
>      const char *current_name;
>      const char *current_builddir;
>  
>      bool        allow_output;
> -    
> +
>      unsigned long long common_ticktime;
>  
>    public:
> -    generate_c_c(stage4out_c *s4o_ptr, const char *builddir):
> +    generate_c_c(stage4out_c *s4o_ptr, const char *builddir):
>              s4o(*s4o_ptr),
>              pous_s4o(builddir, "POUS", "c"),
>              pous_incl_s4o(builddir, "POUS", "h"),
> @@ -2488,7 +2490,7 @@
>        current_configuration = NULL;
>        allow_output = true;
>      }
> -            
> +
>      ~generate_c_c(void) {}
>  
>  
> @@ -2497,24 +2499,24 @@
>  /* 2.1.6 - Pragmas  */
>  /********************/
>      void *visit(enable_code_generation_pragma_c * symbol)  {
> -      s4o                  .enable_output();  
> -      pous_s4o             .enable_output();  
> -      pous_incl_s4o        .enable_output();  
> -      located_variables_s4o.enable_output();  
> -      variables_s4o        .enable_output();  
> -      allow_output = true;      
> +      s4o                  .enable_output();
> +      pous_s4o             .enable_output();
> +      pous_incl_s4o        .enable_output();
> +      located_variables_s4o.enable_output();
> +      variables_s4o        .enable_output();
> +      allow_output = true;
>        return NULL;
>      }
> -    
> +
>      void *visit(disable_code_generation_pragma_c * symbol)  {
> -      s4o                  .disable_output();  
> -      pous_s4o             .disable_output();  
> -      pous_incl_s4o        .disable_output();  
> -      located_variables_s4o.disable_output();  
> -      variables_s4o        .disable_output();  
> -      allow_output = false;      
> +      s4o                  .disable_output();
> +      pous_s4o             .disable_output();
> +      pous_incl_s4o        .disable_output();
> +      located_variables_s4o.disable_output();
> +      variables_s4o        .disable_output();
> +      allow_output = false;
>        return NULL;
> -    }
> +    }
>  
>  
>  /***************************/
> @@ -2522,7 +2524,7 @@
>  /***************************/
>      void *visit(library_c *symbol) {
>        pous_incl_s4o.print("#ifndef __POUS_H\n#define __POUS_H\n\n");
> -      
> +
>        if (runtime_options.disable_implicit_en_eno) {
>          // If we are not generating the EN and ENO parameters for functions and FB,
>          //   then make sure we use the standard library version compiled without these parameters too!
> @@ -2530,7 +2532,7 @@
>          pous_incl_s4o.print("#define DISABLE_EN_ENO_PARAMETERS\n");
>          pous_incl_s4o.print("#endif\n");
>        }
> -      
> +
>        pous_incl_s4o.print("#include \"accessor.h\"\n#include \"iec_std_lib.h\"\n\n");
>  
>        for(int i = 0; i < symbol->n; i++) {
> @@ -2538,7 +2540,7 @@
>        }
>  
>        pous_incl_s4o.print("#endif //__POUS_H\n");
> -      
> +
>        generate_var_list_c generate_var_list(&variables_s4o, symbol);
>        generate_var_list.generate_programs(symbol);
>        generate_var_list.generate_variables(symbol);
> @@ -2561,7 +2563,7 @@
>      /* In the derived datatype and POUs declarations, the names are stored as identfier_c, so the following visitors are not required! */
>      void *visit(derived_datatype_identifier_c *symbol) {ERROR; return NULL;}
>      void *visit(         poutype_identifier_c *symbol) {ERROR; return NULL;}
> -    
> +
>  
>  /********************************/
>  /* B 1.3.3 - Derived data types */
> @@ -2613,12 +2615,12 @@
>  
>  /***********************/
>  /* B 1.5.1 - Functions */
> -/***********************/      
> +/***********************/
>      void *visit(function_declaration_c *symbol) {
>        handle_pou(handle_function,symbol->derived_function_name)
>        return NULL;
>      }
> -    
> +
>  /*****************************/
>  /* B 1.5.2 - Function Blocks */
>  /*****************************/
> @@ -2626,15 +2628,15 @@
>        handle_pou(handle_function_block,symbol->fblock_name)
>        return NULL;
>      }
> -    
> +
>  /**********************/
>  /* B 1.5.3 - Programs */
> -/**********************/    
> +/**********************/
>      void *visit(program_declaration_c *symbol) {
>        handle_pou(handle_program,symbol->program_type_name)
>        return NULL;
>      }
> -    
> +
>  
>  /********************************/
>  /* B 1.7 Configuration elements */
> @@ -2662,7 +2664,7 @@
>          }
>  
>          symbol->configuration_name->accept(*this);
> -        
> +
>          stage4out_c config_s4o(current_builddir, current_name, "c");
>          stage4out_c config_incl_s4o(current_builddir, current_name, "h");
>          generate_c_config_c generate_c_config(&config_s4o, &config_incl_s4o);
> @@ -2707,7 +2709,7 @@
>        symbol->accept(generate_c_resources);
>        return NULL;
>      }
> -    
> +
>  };
>  
>  /***********************************************************************/

> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot

> _______________________________________________
> Beremiz-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/beremiz-devel


--
Best regards,
Andrey Skvortsov

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Beremiz-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beremiz-devel

signature.asc (849 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [Beremiz-devel] [matiec][patch] Fix for greatest_tick_count__ calculation error.

Beremiz-Devel mailing list

Sorry, Mario, this was my mistake to use "smart" editor that "fixed" the code style even without a warning...

Here is thee patch,

Best regards,
PAul Beltyukov

2018-04-23 12:47 GMT+05:00 <[hidden email]>:
On 18-04-23 12:37, [hidden email] wrote:
> Hi, Alexandr, Mario.
>
> I have fixed greatest_tick_count__ calculation error. Now
> greatest_tick_count__ *is* common multiple of all tasks tick counts.
>
> The actual problem is deeper, because we need *statefull timers* to handle
> task scheduling on the high level, but at least we now can have correct
> greatest_tick_count__.
>
> I'sorry but my text editor have "fixed" some more things...

Hi Paul,

if you want to fix code-style warning, I'd recommend you at least to
separate fix of the real problem and fix of code-style. The change
should be easy to read and fix only *one* problem.
Please separate changes, this is not that hard in every editor.


> Best regards,
> Paul Beltyukov

> # HG changeset patch
> # User Paul Beltyukov
> # Date 1524462097 -18000
> #      Mon Apr 23 10:41:37 2018 +0500
> # Node ID 16d239d787731066c4879ead29e1374459e1c876
> # Parent  2dc67df52e5935b16aa93219bfcc558253a41759
> Fixed erronious greatest_tick_count__ calculation.
>
> diff -r 2dc67df52e59 -r 16d239d78773 stage4/generate_c/generate_c.cc
> --- a/stage4/generate_c/generate_c.cc Fri Apr 20 17:40:29 2018 +0100
> +++ b/stage4/generate_c/generate_c.cc Mon Apr 23 10:41:37 2018 +0500
> @@ -30,6 +30,7 @@
>  #include <map>
>  #include <sstream>
>  #include <strings.h>
> +#include <climits>


>  #include "../../util/symtable.hh"
> @@ -54,7 +55,7 @@

>  /* Macros to access the constant value of each expression (if it exists) from the annotation introduced to the symbol_c object by constant_folding_c in stage3! */
>  #define VALID_CVALUE(dtype, symbol)           ((symbol)->const_value._##dtype.is_valid())
> -#define GET_CVALUE(dtype, symbol)             ((symbol)->const_value._##dtype.get())
> +#define GET_CVALUE(dtype, symbol)             ((symbol)->const_value._##dtype.get())



> @@ -184,7 +185,7 @@
>  /* Parse command line options passed from main.c !! */
>  #include <stdlib.h> // for getsubopt()
>  int  stage4_parse_options(char *options) {
> -  enum {LINE_OPT = 0, 
> +  enum {LINE_OPT = 0,
>          SEPTFILE_OPT,
>          BACKUP_OPT    /* option to generate function to backup and restore internal PLC state */
>          /*, SOME_OTHER_OPT, YET_ANOTHER_OPT */};
> @@ -195,7 +196,7 @@
>          /* SOME_OTHER_OPT, ...             */
>          NULL };
>    /* unfortunately, the above commented out syntax for array initialization is valid in C, but not in C++ */
> - 
> +
>    char *subopts = options;
>    char *value;
>    int opt;
> @@ -207,23 +208,23 @@
>        case   BACKUP_OPT: generate_plc_state_backup_fuctions__  = 1; break;
>        default          : fprintf(stderr, "Unrecognized option: -O %s\n", value); return -1; break;
>       }
> -  }     
> +  }
>    return 0;
>  }


>  void stage4_print_options(void) {
> -  printf("          (options must be separated by commas. Example: 'l,w,x')\n");
> -  printf("      l : insert '#line' directives in generated C code.\n");
> -  printf("      p : place each POU in a separate pair of files (<pou_name>.c, <pou_name>.h).\n");
> -  printf("      b : generate functions to backup and restore internal PLC state.\n");
> +  printf("          (options must be separated by commas. Example: 'l,w,x')\n");
> +  printf("      l : insert '#line' directives in generated C code.\n");
> +  printf("      p : place each POU in a separate pair of files (<pou_name>.c, <pou_name>.h).\n");
> +  printf("      b : generate functions to backup and restore internal PLC state.\n");
>  }
>  #else /* not __unix__ */
> -/* getsubopt isn't supported with mingw,
> +/* getsubopt isn't supported with mingw,
>   *  then stage4 options aren't available on windows*/
>  void stage4_print_options(void) {}
>  int  stage4_parse_options(char *options) {return 0;}
> -#endif
> +#endif

>  /***********************************************************************/
>  /***********************************************************************/
> @@ -253,10 +254,10 @@
>  /***********************************************************************/

>  /* A helper class that prints out the identifiers for function calls to overloaded functions */
> -/* Given a function declaration of the function being called, it
> +/* Given a function declaration of the function being called, it
>   * will simply print out the returned data type,
>   * followed by the data types of all input, output, and in_out parameters.
> - *   for e.g.;
> + *   for e.g.;
>   *     SIN( REAL) : REAL      -> prints out ->  REAL__REAL
>   *     LEN( STRING) : INT     -> prints out ->  INT__STRING
>   *     MUL(TIME, INT) : TIME  -> prints out ->  TIME__TIME__INT
> @@ -266,20 +267,20 @@
>      symbol_c *current_type;
>      bool_type_name_c tmp_bool;

> -    void print_list(symbol_c *var_list, symbol_c *data_type) {
> +    void print_list(symbol_c *var_list, symbol_c *data_type) {
>        if (data_type != NULL) {
>          /* print out the data type once for every variable! */
>          list_c *list = dynamic_cast<list_c *>(var_list);
> -        if (list == NULL) ERROR; 
> +        if (list == NULL) ERROR;
>          for (int i=0; i < list->n; i++) {
>            s4o.print("__");
>            data_type->accept(*this);
> -        } 
> +        }
>        }
>      }
> -   
> +
>    public:
> -    print_function_parameter_data_types_c(stage4out_c *s4o_ptr):
> +    print_function_parameter_data_types_c(stage4out_c *s4o_ptr):
>        generate_c_base_and_typeid_c(s4o_ptr)
>        {current_type = NULL;}

> @@ -299,35 +300,35 @@

>      /* already handled by iterator base class (note that generate_c_base_c inherits from iterator_c) */
>      //void *visit(var_declarations_list_c *symbol) {// iterate through list}
> -   
> +
>      /* already handled by iterator base class (note that generate_c_base_c inherits from iterator_c) */
>      //void *visit(input_declarations_c *symbol) {// iterate through list}
> -       
> +
>      /* already handled by iterator base class (note that generate_c_base_c inherits from iterator_c) */
>      //void *visit(input_declaration_list_c *symbol) {// iterate through list}

>      void *visit(edge_declaration_c *symbol) {
>        {STAGE4_ERROR(symbol, symbol, "R_EDGE and F_EDGE declarations are not currently supported"); ERROR;}
> -      /*
> -      current_type = &tmp_bool;
> +      /*
> +      current_type = &tmp_bool;
>        symbol->var1_list->accept(*this);
> -      current_type = NULL;
> +      current_type = NULL;
>        */
>        return NULL;
>      }
> -   
> +
>      /* We do NOT print out EN and ENO parameters! */
>      void *visit(en_param_declaration_c *symbol) {return NULL;}

>      /* already handled by iterator base class (note that generate_c_base_c inherits from iterator_c) */
> -    //void *visit(output_declarations_c *symbol) {// iterate through list}   
> -   
> +    //void *visit(output_declarations_c *symbol) {// iterate through list}
> +
>      /* already handled by iterator base class (note that generate_c_base_c inherits from iterator_c) */
>      //void *visit(var_init_decl_list_c *symbol) {// iterate through list}

>      void *visit(simple_spec_init_c *symbol) {
>        /* return the data type */
> -      return symbol->simple_specification;
> +      return symbol->simple_specification;
>      }

>      /* currently we do not support data types defined in the declaration itself */
> @@ -362,13 +363,13 @@
>      void *visit(eno_param_declaration_c *symbol) {return NULL;}

>      /* already handled by iterator base class (note that generate_c_base_c inherits from iterator_c) */
> -    //void *visit(input_output_declarations_c *symbol) {// iterate through list}   
> +    //void *visit(input_output_declarations_c *symbol) {// iterate through list}

>      /* already handled by iterator base class (note that generate_c_base_c inherits from iterator_c) */
>      //void *visit(var_declaration_list_c *symbol) {iterate through list}

>      void *visit(fb_name_decl_c *symbol) {
> -      print_list(symbol->fb_name_list, spec_init_sperator_c::get_spec(symbol->fb_spec_init));
> +      print_list(symbol->fb_name_list, spec_init_sperator_c::get_spec(symbol->fb_spec_init));
>        return NULL;
>      }

> @@ -382,9 +383,9 @@
>      void *visit(array_var_declaration_c *symbol) {return NULL;}

>      void *visit(structured_var_declaration_c *symbol) {
> -      current_type = symbol->structure_type_name;
> +      current_type = symbol->structure_type_name;
>        symbol->var1_list->accept(*this);
> -      current_type = NULL;
> +      current_type = NULL;
>        return NULL;
>      }

> @@ -402,7 +403,7 @@
>       */
>      void *visit(double_byte_string_var_declaration_c *symbol) {return NULL;}
>  };
> -   
> +

>  /***********************************************************************/
>  /***********************************************************************/
> @@ -417,20 +418,20 @@

>    public:
>      analyse_variable_c(void) {};
> -   
> +
>      static bool is_complex_type(symbol_c *symbol) {
>        if (NULL == symbol) ERROR;
>        if (!get_datatype_info_c::is_type_valid     (symbol->datatype)) return false;
> -      return (   get_datatype_info_c::is_structure(symbol->datatype)
> -              || get_datatype_info_c::is_array    (symbol->datatype)
> +      return (   get_datatype_info_c::is_structure(symbol->datatype)
> +              || get_datatype_info_c::is_array    (symbol->datatype)
>               );
>      }

> -   
> +
>    private:
>      symbol_c *last_fb, *first_non_fb_identifier;

> -  public: 
> +  public:
>      /* returns the first element (from left to right) in a structured variable that is not a FB, i.e. is either a structure or an array! */
>      /* eg:
>       *      fb1.fb2.fb3.real       returns ??????
> @@ -441,12 +442,12 @@
>        if (NULL == singleton_)       singleton_ = new analyse_variable_c();
>        if (NULL == singleton_)       ERROR;
>        if (NULL == symbol)           ERROR;
> -     
> +
>        singleton_->last_fb                 = NULL;
>        singleton_->first_non_fb_identifier = NULL;
>        return (symbol_c *)symbol->accept(*singleton_);
>      }
> -   
> +
>      /* returns true if a strcutured variable (e.g. fb1.fb2.strcut1.real) contains a structure or array */
>      /* eg:
>       *      fb1.fb2.fb3.real       returns FALSE
> @@ -456,12 +457,12 @@
>      static bool contains_complex_type(symbol_c *symbol) {
>        if (NULL == symbol) ERROR;
>        if (!get_datatype_info_c::is_type_valid(symbol->datatype)) ERROR;
> -     
> +
>        symbol_c *first_non_fb = (symbol_c *)find_first_nonfb(symbol);
>        return is_complex_type(first_non_fb->datatype);
>      }
> -   
> -   
> +
> +
>      /* returns the datatype of the variable returned by find_first_nonfb() */
>      /* eg:
>       *      fb1.fb2.fb3.real       returns ??????
> @@ -471,60 +472,60 @@
>      static search_var_instance_decl_c::vt_t first_nonfb_vardecltype(symbol_c *symbol, symbol_c *scope) {
>        if (NULL == symbol) ERROR;
>        if (!get_datatype_info_c::is_type_valid(symbol->datatype)) ERROR;
> -     
> +
>        symbol_c *first_non_fb = (symbol_c *)find_first_nonfb(symbol);
>        if (NULL != singleton_->last_fb) {
>          scope = singleton_->last_fb->datatype;
>          symbol = singleton_->first_non_fb_identifier;
>        }
> -     
> +
>        search_var_instance_decl_c search_var_instance_decl(scope);
> -     
> +
>        return search_var_instance_decl.get_vartype(symbol);
>      }
> -   
> -   
> +
> +
>      /*********************/
>      /* B 1.4 - Variables */
>      /*********************/
>      void *visit(symbolic_variable_c *symbol) {
>        if (!get_datatype_info_c::is_type_valid    (symbol->datatype)) ERROR;
>        if (!get_datatype_info_c::is_function_block(symbol->datatype)) {
> -         first_non_fb_identifier = symbol;
> +         first_non_fb_identifier = symbol;
>           return (void *)symbol;
>        }
>        last_fb = symbol;
>        return NULL;
>      }
> -   
> +
>      /*************************************/
>      /* B.1.4.2   Multi-element Variables */
>      /*************************************/
> -   
> +
>      // SYM_REF2(structured_variable_c, record_variable, field_selector)
>      void *visit(structured_variable_c *symbol) {
>        symbol_c *res = (symbol_c *)symbol->record_variable->accept(*this);
>        if (NULL != res) return res;
> -     
> +
>        if (!get_datatype_info_c::is_type_valid    (symbol->datatype)) ERROR;
>        if (!get_datatype_info_c::is_function_block(symbol->datatype)) {
> -         first_non_fb_identifier = symbol->field_selector;
> +         first_non_fb_identifier = symbol->field_selector;
>           return (void *)symbol;
>        }

> -      last_fb = symbol;     
> -      return NULL;     
> +      last_fb = symbol;
> +      return NULL;
>      }
> -   
> +
>      /*  subscripted_variable '[' subscript_list ']' */
>      //SYM_REF2(array_variable_c, subscripted_variable, subscript_list)
>      void *visit(array_variable_c *symbol) {
>        void *res = symbol->subscripted_variable->accept(*this);
>        if (NULL != res) return res;
> -      return (void *)symbol;     
> +      return (void *)symbol;
>      }

> -   
> +
>  };

>  analyse_variable_c *analyse_variable_c::singleton_ = NULL;
> @@ -549,10 +550,10 @@

>  unsigned long long calculate_time(symbol_c *symbol) {
>    if (NULL == symbol) return 0;
> - 
> +
>    interval_c *interval = dynamic_cast<interval_c *>(symbol);
>    duration_c *duration = dynamic_cast<duration_c *>(symbol);
> - 
> +
>    if ((NULL == interval) && (NULL == duration))
>         {STAGE4_ERROR(symbol, symbol, "This type of interval value is not currently supported"); ERROR;}

> @@ -565,13 +566,13 @@

>    if (NULL != interval) {
>      /* SYM_REF5(interval_c, days, hours, minutes, seconds, milliseconds) */
> -      unsigned long long int time_ull = 0;
> +      unsigned long long int time_ull = 0;
>        long double            time_ld  = 0;
>        /*
>        const unsigned long long int MILLISECOND = 1000000;
>        const unsigned long long int      SECOND = 1000 * MILLISECOND
>        */
> -     
> +
>        if (NULL != interval->milliseconds) {
>          if      (VALID_CVALUE( int64, interval->milliseconds) &&           GET_CVALUE( int64, interval->milliseconds) < 0) ERROR; // interval elements should always be positive!
>          if      (VALID_CVALUE( int64, interval->milliseconds)) time_ull += GET_CVALUE( int64, interval->milliseconds) * MILLISECOND;
> @@ -579,7 +580,7 @@
>          else if (VALID_CVALUE(real64, interval->milliseconds)) time_ld  += GET_CVALUE(real64, interval->milliseconds) * MILLISECOND;
>          else ERROR; // if (NULL != interval->milliseconds) is true, then it must have a valid constant value!
>        }
> -   
> +
>        if (NULL != interval->seconds     ) {
>          if      (VALID_CVALUE( int64, interval->seconds     ) &&           GET_CVALUE( int64, interval->seconds     ) < 0) ERROR; // interval elements should always be positive!
>          if      (VALID_CVALUE( int64, interval->seconds     )) time_ull += GET_CVALUE( int64, interval->seconds     ) * SECOND;
> @@ -628,13 +629,13 @@
>    private:
>      unsigned long long common_ticktime;
>      unsigned long long least_common_ticktime;
> -   
> +
>    public:
>      calculate_common_ticktime_c(void){
>        common_ticktime = 0;
>        least_common_ticktime = 0;
>      }
> -   
> +
>      unsigned long long euclide(unsigned long long a, unsigned long long b) {
>        unsigned long long c = a % b;
>        if (c == 0)
> @@ -642,7 +643,7 @@
>        else
>          return euclide(b, c);
>      }
> -   
> +
>      void update_ticktime(unsigned long long time) {
>        if (common_ticktime == 0)
>          common_ticktime = time;
> @@ -664,11 +665,12 @@
>        unsigned long long least_common_tick = least_common_ticktime / common_ticktime;
>        if (least_common_tick >> 32)
>          ERROR;
> -      return (unsigned long)(~(((unsigned long)-1) % (unsigned long)least_common_tick) + 1);
> +      //return (unsigned long)(~(((unsigned long)-1) % (unsigned long)least_common_tick) + 1);
> +      return (unsigned long)(ULONG_MAX - ((ULONG_MAX) % (unsigned long)least_common_tick));
>      }

>  /*  TASK task_name task_initialization */
> -//SYM_REF2(task_configuration_c, task_name, task_initialization) 
> +//SYM_REF2(task_configuration_c, task_name, task_initialization)
>      void *visit(task_initialization_c *symbol) {
>        if (symbol->interval_data_source != NULL) {
>         unsigned long long time = calculate_time(symbol->interval_data_source);
> @@ -677,7 +679,7 @@
>        }
>        return NULL;
>      }
> -};   
> +};

>  /***********************************************************************/
>  /***********************************************************************/
> @@ -694,31 +696,31 @@

>    public:
>      generate_c_SFC_IL_ST_c(stage4out_c *s4o_ptr, symbol_c *name, symbol_c *scope, const char *variable_prefix = NULL);
> -   
> +
>      /********************/
>      /* 2.1.6 - Pragmas  */
>      /********************/
>      void *visit(enable_code_generation_pragma_c * symbol)   {s4o_ptr->enable_output();  return NULL;}
> -    void *visit(disable_code_generation_pragma_c * symbol)  {s4o_ptr->disable_output(); return NULL;}
> -   
> +    void *visit(disable_code_generation_pragma_c * symbol)  {s4o_ptr->disable_output(); return NULL;}
> +
>      /*********************************************/
>      /* B.1.6  Sequential function chart elements */
>      /*********************************************/
>      /*| sequential_function_chart sfc_network*/
>      void *visit(sequential_function_chart_c * symbol);
> -   
> +
>      /****************************************/
>      /* B.2 - Language IL (Instruction List) */
>      /****************************************/
> -   
> +
>      /***********************************/
>      /* B 2.1 Instructions and Operands */
>      /***********************************/
>      /*| instruction_list il_instruction */
>      void *visit(instruction_list_c *symbol);
> -   
> +
>      /* Remainder implemented in generate_c_il_c... */
> -   
> +
>      /***************************************/
>      /* B.3 - Language ST (Structured Text) */
>      /***************************************/
> @@ -726,7 +728,7 @@
>      /* B 3.1 - Expressions */
>      /***********************/
>      /* Implemented in generate_c_st_c */
> -   
> +
>      /********************/
>      /* B 3.2 Statements */
>      /********************/
> @@ -777,11 +779,11 @@
>  /***********************************************************************/
>  /***********************************************************************/

> -class generate_c_pous_c { 
> +class generate_c_pous_c {
>    /* NOTE: This is NOT a visistor class!!
> -   *
> +   *
>     *       Actually, it does not even really need to be a class. It is simply a collection of similar functions!!
> -   */
> +   */

>    private:
>      static void print_end_of_block_label(stage4out_c &s4o) {
> @@ -806,7 +808,7 @@
>        s4o.print(":\n");
>        s4o.indent_right();
>      }
> - 
> +

>      /*************/
>      /* Functions */
> @@ -823,9 +825,9 @@
>      static void handle_function(function_declaration_c *symbol, stage4out_c &s4o, bool print_declaration) {
>        generate_c_vardecl_c          *vardecl = NULL;
>        generate_c_base_and_typeid_c   print_base(&s4o);
> -     
> +
>        TRACE("function_declaration_c");
> -   
> +
>        /* (A) Function declaration... */
>        /* (A.1) Function return type */
>        s4o.print("// FUNCTION\n");
> @@ -834,7 +836,7 @@
>        /* (A.2) Function name */
>        symbol->derived_function_name->accept(print_base);
>        s4o.print("(");
> -   
> +
>        /* (A.3) Function parameters */
>        s4o.indent_right();
>        vardecl = new generate_c_vardecl_c(&s4o,
> @@ -846,22 +848,22 @@
>                                           generate_c_vardecl_c::eno_vt);
>        vardecl->print(symbol->var_declarations_list);
>        delete vardecl;
> -     
> +
>        s4o.indent_left();
> -     
> +
>        s4o.print(")");
> -     
> +
>        /* If we only want the declaration/prototype, then return!! */
> -      if (print_declaration)
> +      if (print_declaration)
>          {s4o.print(";\n"); return;}
> -     
> +
>        /* continue generating the function definition/code... */
>        s4o.print("\n" + s4o.indent_spaces + "{\n");
> -   
> +
>        /* (B) Function local variable declaration */
>        /* (B.1) Variables declared in ST source code */
>        s4o.indent_right();
> -     
> +
>        vardecl = new generate_c_vardecl_c(&s4o,
>                      generate_c_vardecl_c::localinit_vf,
>                      generate_c_vardecl_c::output_vt   |
> @@ -870,7 +872,7 @@
>                      generate_c_vardecl_c::eno_vt);
>        vardecl->print(symbol->var_declarations_list);
>        delete vardecl;
> -   
> +
>        /* (B.2) Temporary variable for function's return value */
>        /* It will have the same name as the function itself! */
>        /* NOTE: matiec supports a non-standard syntax, in which functions do not return a value
> @@ -878,7 +880,7 @@
>         *       e.g.:   FUNCTION foo: VOID
>         *                ...
>         *               END_FUNCTION
> -       *       
> +       *
>         *       These functions cannot return any value, so they do not need a variable to
>         *       store the return value.
>         *       Note that any attemot to sto a value in the implicit variable
> @@ -886,7 +888,7 @@
>         *                ...
>         *                 foo := 42;
>         *               END_FUNCTION
> -       *       will always return a datatype incompatilibiyt error in stage 3 of matiec,
> +       *       will always return a datatype incompatilibiyt error in stage 3 of matiec,
>         *       so it is safe for stage 4 to assume that this return variable will never be needed
>         *       if the function's return type is VOID.
>         */
> @@ -925,8 +927,8 @@
>          }
>        }
>        s4o.print(";\n\n");
> -     
> -     
> +
> +
>        // Only generate the code that controls the execution of the function's body if the
>        // function contains a declaration of both the EN and ENO variables
>        search_var_instance_decl_c search_var(symbol);
> @@ -950,13 +952,13 @@
>          s4o.indent_left();
>          s4o.print(s4o.indent_spaces + "}\n");
>        }
> -   
> +
>        /* (C) Function body */
>        generate_c_SFC_IL_ST_c generate_c_code(&s4o, symbol->derived_function_name, symbol);
>        symbol->function_body->accept(generate_c_code);
> -     
> +
>        print_end_of_block_label(s4o);
> -     
> +
>        vardecl = new generate_c_vardecl_c(&s4o,
>                      generate_c_vardecl_c::foutputassign_vf,
>                      generate_c_vardecl_c::output_vt   |
> @@ -964,7 +966,7 @@
>                      generate_c_vardecl_c::eno_vt);
>        vardecl->print(symbol->var_declarations_list);
>        delete vardecl;
> -     
> +
>        if (!get_datatype_info_c::is_VOID(symbol->type_name->datatype)) { // only print 'return <fname>' if return datatype is not VOID
>          s4o.print(s4o.indent_spaces + "return ");
>          symbol->derived_function_name->accept(print_base);
> @@ -973,11 +975,11 @@

>        s4o.indent_left();
>        s4o.print(s4o.indent_spaces + "}\n\n\n");
> -   
> +
>        return;
>      }
> -   
> -   
> +
> +
>      /*******************/
>      /* Function Blocks */
>      /*******************/
> @@ -995,7 +997,7 @@
>        generate_c_sfcdecl_c          *sfcdecl;
>        generate_c_base_and_typeid_c   print_base(&s4o);
>        TRACE("function_block_declaration_c");
> -   
> +
>        /* (A) Function Block data structure declaration... */
>        if (print_declaration) {
>          /* (A.1) Data structure declaration */
> @@ -1028,34 +1030,34 @@
>                                             generate_c_vardecl_c::external_vt);
>          vardecl->print(symbol->var_declarations);
>          delete vardecl;
> -       
> +
>          /* (A.4) Generate private internal variables for SFC */
>          sfcdecl = new generate_c_sfcdecl_c(&s4o, symbol);
>          sfcdecl->generate(symbol->fblock_body, generate_c_sfcdecl_c::sfcdecl_sd);
>          delete sfcdecl;
>          s4o.print("\n");
> -     
> +
>          /* (A.5) Function Block data structure type name. */
>          s4o.indent_left();
>          s4o.print("} ");
>          symbol->fblock_name->accept(print_base);
>          s4o.print(";\n\n");
>        }
> -     
> +
>        if (!print_declaration) {
>          /* (A.6) Function Block inline function declaration for function invocation */
>          generate_c_inlinefcall_c *inlinedecl = new generate_c_inlinefcall_c(&s4o, symbol->fblock_name, symbol, FB_FUNCTION_PARAM"->");
>          symbol->fblock_body->accept(*inlinedecl);
>          delete inlinedecl;
>        }
> -     
> +
>        /* (B) Constructor */
>        /* (B.1) Constructor name... */
>        s4o.print(s4o.indent_spaces + "void ");
>        symbol->fblock_name->accept(print_base);
>        s4o.print(FB_INIT_SUFFIX);
>        s4o.print("(");
> -   
> +
>        /* first and only parameter is a pointer to the data */
>        symbol->fblock_name->accept(print_base);
>        s4o.print(" *");
> @@ -1067,7 +1069,7 @@
>        } else {
>          s4o.print(" {\n");
>          s4o.indent_right();
> -     
> +
>          /* (B.2) Member initializations... */
>          s4o.print(s4o.indent_spaces);
>          vardecl = new generate_c_vardecl_c(&s4o,
> @@ -1083,23 +1085,23 @@
>          vardecl->print(symbol->var_declarations, NULL, FB_FUNCTION_PARAM"->");
>          delete vardecl;
>          s4o.print("\n");
> -           
> +
>          /* (B.3) Generate private internal variables for SFC */
>          sfcdecl = new generate_c_sfcdecl_c(&s4o, symbol, FB_FUNCTION_PARAM"->");
>          sfcdecl->generate(symbol->fblock_body, generate_c_sfcdecl_c::sfcinit_sd);
> -     
> +
>          s4o.indent_left();
>          s4o.print(s4o.indent_spaces + "}\n\n");

>          /* (C) Function with FB body */
>          /* (C.1) Step definitions */
>          sfcdecl->generate(symbol->fblock_body, generate_c_sfcdecl_c::stepdef_sd);
> -     
> +
>          /* (C.2) Action definitions */
>          sfcdecl->generate(symbol->fblock_body, generate_c_sfcdecl_c::actiondef_sd);
>          delete sfcdecl;
>        }
> -     
> +
>        /* (C.3) Function declaration */
>        s4o.print("// Code part\n");
>        /* function interface */
> @@ -1152,7 +1154,7 @@
>            s4o.indent_left();
>            s4o.print(s4o.indent_spaces + "}\n");
>          }
> -     
> +
>          /* (C.4) Initialize TEMP variables */
>          /* function body */
>          s4o.print(s4o.indent_spaces + "// Initialise TEMP variables\n");
> @@ -1162,7 +1164,7 @@
>          vardecl->print(symbol->var_declarations, NULL,  FB_FUNCTION_PARAM"->");
>          delete vardecl;
>          s4o.print("\n");
> -     
> +
>          /* (C.5) Function code */
>          generate_c_SFC_IL_ST_c generate_c_code(&s4o, symbol->fblock_name, symbol, FB_FUNCTION_PARAM"->");
>          symbol->fblock_body->accept(generate_c_code);
> @@ -1173,22 +1175,22 @@
>          symbol->fblock_name->accept(print_base);
>          s4o.print(FB_FUNCTION_SUFFIX);
>          s4o.print(s4o.indent_spaces + "() \n\n");
> -     
> +
>          /* (C.6) Step undefinitions */
>          sfcdecl = new generate_c_sfcdecl_c(&s4o, symbol, FB_FUNCTION_PARAM"->");
>          sfcdecl->generate(symbol->fblock_body, generate_c_sfcdecl_c::stepundef_sd);
> -     
> +
>          /* (C.7) Action undefinitions */
>          sfcdecl->generate(symbol->fblock_body, generate_c_sfcdecl_c::actionundef_sd);
>          delete sfcdecl;
> -     
> +
>          s4o.indent_left();
>          s4o.print("\n\n\n\n");
>        }
>        return;
>      }
> -   
> -   
> +
> +
>      /************/
>      /* Programs */
>      /************/
> @@ -1206,16 +1208,16 @@
>        generate_c_sfcdecl_c          *sfcdecl;
>        generate_c_base_and_typeid_c   print_base(&s4o);
>        TRACE("program_declaration_c");
> -   
> +
>        /* (A) Program data structure declaration... */
> -      if (print_declaration) {     
> +      if (print_declaration) {
>          /* (A.1) Data structure declaration */
>          s4o.print("// PROGRAM ");
>          symbol->program_type_name->accept(print_base);
>          s4o.print("\n// Data part\n");
>          s4o.print("typedef struct {\n");
>          s4o.indent_right();
> -     
> +
>          /* (A.2) Public variables: i.e. the program parameters... */
>          s4o.print(s4o.indent_spaces + "// PROGRAM Interface - IN, OUT, IN_OUT variables\n");
>          vardecl = new generate_c_vardecl_c(&s4o,
> @@ -1226,7 +1228,7 @@
>          vardecl->print(symbol->var_declarations);
>          delete vardecl;
>          s4o.print("\n");
> - 
> +
>          /* (A.3) Private internal variables */
>          s4o.print(s4o.indent_spaces + "// PROGRAM private variables - TEMP, private and located variables\n");
>          vardecl = new generate_c_vardecl_c(&s4o,
> @@ -1237,34 +1239,34 @@
>                        generate_c_vardecl_c::external_vt);
>          vardecl->print(symbol->var_declarations);
>          delete vardecl;
> -     
> +
>          /* (A.4) Generate private internal variables for SFC */
>          sfcdecl = new generate_c_sfcdecl_c(&s4o, symbol);
>          sfcdecl->generate(symbol->function_block_body, generate_c_sfcdecl_c::sfcdecl_sd);
>          delete sfcdecl;
>          s4o.print("\n");
> -       
> +
>          /* (A.5) Program data structure type name. */
>          s4o.indent_left();
>          s4o.print("} ");
>          symbol->program_type_name->accept(print_base);
>          s4o.print(";\n\n");
>        }
> -     
> -      if (!print_declaration) {     
> +
> +      if (!print_declaration) {
>          /* (A.6) Function Block inline function declaration for function invocation */
>          generate_c_inlinefcall_c *inlinedecl = new generate_c_inlinefcall_c(&s4o, symbol->program_type_name, symbol, FB_FUNCTION_PARAM"->");
>          symbol->function_block_body->accept(*inlinedecl);
>          delete inlinedecl;
>        }
> -   
> +
>        /* (B) Constructor */
>        /* (B.1) Constructor name... */
>        s4o.print(s4o.indent_spaces + "void ");
>        symbol->program_type_name->accept(print_base);
>        s4o.print(FB_INIT_SUFFIX);
>        s4o.print("(");
> -   
> +
>        /* first and only parameter is a pointer to the data */
>        symbol->program_type_name->accept(print_base);
>        s4o.print(" *");
> @@ -1276,7 +1278,7 @@
>        } else {
>          s4o.print(" {\n");
>          s4o.indent_right();
> -     
> +
>          /* (B.2) Member initializations... */
>          s4o.print(s4o.indent_spaces);
>          vardecl = new generate_c_vardecl_c(&s4o,
> @@ -1290,27 +1292,27 @@
>          vardecl->print(symbol->var_declarations, NULL,  FB_FUNCTION_PARAM"->");
>          delete vardecl;
>          s4o.print("\n");
> -     
> +
>          /* (B.3) Generate private internal variables for SFC */
>          sfcdecl = new generate_c_sfcdecl_c(&s4o, symbol, FB_FUNCTION_PARAM"->");
>          sfcdecl->generate(symbol->function_block_body, generate_c_sfcdecl_c::sfcinit_sd);
>          delete sfcdecl;
> -     
> +
>          s4o.indent_left();
>          s4o.print(s4o.indent_spaces + "}\n\n");
>        }
> -   
> -      if (!print_declaration) {   
> +
> +      if (!print_declaration) {
>          /* (C) Function with PROGRAM body */
>          /* (C.1) Step definitions */
>          sfcdecl = new generate_c_sfcdecl_c(&s4o, symbol, FB_FUNCTION_PARAM"->");
>          sfcdecl->generate(symbol->function_block_body, generate_c_sfcdecl_c::stepdef_sd);
> -     
> +
>          /* (C.2) Action definitions */
>          sfcdecl->generate(symbol->function_block_body, generate_c_sfcdecl_c::actiondef_sd);
>          delete sfcdecl;
>        }
> -     
> +
>        /* (C.3) Function declaration */
>        s4o.print("// Code part\n");
>        /* function interface */
> @@ -1329,7 +1331,7 @@
>        } else {
>          s4o.print(" {\n");
>          s4o.indent_right();
> -         
> +
>          /* (C.4) Initialize TEMP variables */
>          /* function body */
>          s4o.print(s4o.indent_spaces + "// Initialise TEMP variables\n");
> @@ -1339,7 +1341,7 @@
>          vardecl->print(symbol->var_declarations, NULL,  FB_FUNCTION_PARAM"->");
>          delete vardecl;
>          s4o.print("\n");
> -     
> +
>          /* (C.5) Function code */
>          generate_c_SFC_IL_ST_c generate_c_code(&s4o, symbol->program_type_name, symbol, FB_FUNCTION_PARAM"->");
>          symbol->function_block_body->accept(generate_c_code);
> @@ -1350,23 +1352,23 @@
>          symbol->program_type_name->accept(print_base);
>          s4o.print(FB_FUNCTION_SUFFIX);
>          s4o.print(s4o.indent_spaces + "() \n\n");
> -     
> +
>          /* (C.6) Step undefinitions */
>          sfcdecl = new generate_c_sfcdecl_c(&s4o, symbol, FB_FUNCTION_PARAM"->");
>          sfcdecl->generate(symbol->function_block_body, generate_c_sfcdecl_c::stepundef_sd);
> -       
> +
>          /* (C.7) Action undefinitions */
> -        sfcdecl->generate(symbol->function_block_body, generate_c_sfcdecl_c::actionundef_sd);
> +        sfcdecl->generate(symbol->function_block_body, generate_c_sfcdecl_c::actionundef_sd);
>          delete sfcdecl;
> -     
> +
>          s4o.indent_left();
>          s4o.print("\n\n\n\n");
> -      } 
> +      }
>        return;
>      }
>  }; /* generate_c_pous_c */

> -   
> +
>  /***********************************************************************/
>  /***********************************************************************/
>  /***********************************************************************/
> @@ -1379,7 +1381,7 @@
>  class generate_c_config_c: public generate_c_base_and_typeid_c {
>      private:
>      stage4out_c &s4o_incl;
> -   
> +
>      public:
>      generate_c_config_c(stage4out_c *s4o_ptr, stage4out_c *s4o_incl_ptr)
>        : generate_c_base_and_typeid_c(s4o_ptr), s4o_incl(*s4o_incl_ptr) {
> @@ -1396,7 +1398,7 @@

>      declaretype_t wanted_declaretype;

> -   
> +
>  public:
>  /********************/
>  /* 2.1.6 - Pragmas  */
> @@ -1409,11 +1411,11 @@

>  void *visit(disable_code_generation_pragma_c * symbol)  {
>      s4o.disable_output();
> -    s4o_incl.disable_output();   
> +    s4o_incl.disable_output();
>      return NULL;
>  }
> -   
> -   
> +
> +
>  /********************************/
>  /* B 1.7 Configuration elements */
>  /********************************/
> @@ -1430,13 +1432,13 @@
>  */
>  void *visit(configuration_declaration_c *symbol) {
>    generate_c_vardecl_c *vardecl;
> - 
> +
>    /* Insert the header... */
>    s4o.print("/*******************************************/\n");
>    s4o.print("/*     FILE GENERATED BY iec2c             */\n");
>    s4o.print("/* Editing this file is not recommended... */\n");
>    s4o.print("/*******************************************/\n\n");
> - 
> +
>    if (runtime_options.disable_implicit_en_eno) {
>      // If we are not generating the EN and ENO parameters for functions and FB,
>      //   then make sure we use the standard library version compiled without these parameters too!
> @@ -1444,9 +1446,9 @@
>      s4o.print("#define DISABLE_EN_ENO_PARAMETERS\n");
>      s4o.print("#endif\n");
>    }
> - 
> +
>    s4o.print("#include \"iec_std_lib.h\"\n\n");
> -  s4o.print("#include \"accessor.h\"\n\n");
> +  s4o.print("#include \"accessor.h\"\n\n");
>    s4o.print("#include \"POUS.h\"\n\n");

>    /* (A) configuration declaration... */
> @@ -1454,7 +1456,7 @@
>    s4o.print("// CONFIGURATION ");
>    symbol->configuration_name->accept(*this);
>    s4o.print("\n");
> - 
> +
>    /* (A.2) Global variables */
>    vardecl = new generate_c_vardecl_c(&s4o,
>                                       generate_c_vardecl_c::local_vf,
> @@ -1478,7 +1480,7 @@
>    wanted_declaretype = initprotos_dt;
>    symbol->resource_declarations->accept(*this);
>    s4o.print("\n");
> - 
> +
>    /* (B.2) Initialisation function name... */
>    s4o.print(s4o.indent_spaces + "void config");
>    s4o.print(FB_INIT_SUFFIX);
> @@ -1488,7 +1490,7 @@
>    s4o.print("BOOL retain;\n");
>    s4o.print(s4o.indent_spaces);
>    s4o.print("retain = 0;\n");
> - 
> +
>    /* (B.3) Global variables initializations... */
>    s4o.print(s4o.indent_spaces);
>    vardecl = new generate_c_vardecl_c(&s4o,
> @@ -1498,11 +1500,11 @@
>    vardecl->print(symbol);
>    delete vardecl;
>    s4o.print("\n");
> - 
> +
>    /* (B.3) Resources initializations... */
>    wanted_declaretype = initdeclare_dt;
>    symbol->resource_declarations->accept(*this);
> - 
> +
>    s4o.indent_left();
>    s4o.print(s4o.indent_spaces + "}\n\n");

> @@ -1637,7 +1639,7 @@
>      declaretype_t wanted_declaretype;

>      unsigned long long common_ticktime;
> -   
> +
>      const char *current_program_name;

>      typedef enum {
> @@ -1688,8 +1690,8 @@
>      /* 2.1.6 - Pragmas  */
>      /********************/
>      void *visit(enable_code_generation_pragma_c * symbol)   {s4o.enable_output();  return NULL;}
> -    void *visit(disable_code_generation_pragma_c * symbol)  {s4o.disable_output(); return NULL;}
> -   
> +    void *visit(disable_code_generation_pragma_c * symbol)  {s4o.disable_output(); return NULL;}
> +

>      /******************************************/
>      /* B 1.4.3 - Declaration & Initialisation */
> @@ -1728,9 +1730,9 @@
>      void *visit(resource_declaration_c *symbol) {
>        current_resource_name = symbol->resource_name;
>        current_global_vars = symbol->global_var_declarations;
> -     
> +
>        symbol->resource_declaration->accept(*this);
> -     
> +
>        current_resource_name = NULL;
>        current_global_vars = NULL;
>        return NULL;
> @@ -1743,13 +1745,13 @@
>        if (single_resource)
>          current_resource_name = new identifier_c("RESOURCE");
>        generate_c_vardecl_c *vardecl;
> -     
> +
>        /* Insert the header... */
>        s4o.print("/*******************************************/\n");
>        s4o.print("/*     FILE GENERATED BY iec2c             */\n");
>        s4o.print("/* Editing this file is not recommended... */\n");
>        s4o.print("/*******************************************/\n\n");
> - 
> +
>        if (runtime_options.disable_implicit_en_eno) {
>          // If we are not generating the EN and ENO parameters for functions and FB,
>          //   then make sure we use the standard library version compiled without these parameters too!
> @@ -1757,15 +1759,15 @@
>          s4o.print("#define DISABLE_EN_ENO_PARAMETERS\n");
>          s4o.print("#endif\n");
>        }
> -     
> +
>        s4o.print("#include \"iec_std_lib.h\"\n\n");
> -     
> +
>        /* (A) resource declaration... */
>        /* (A.1) resource name in comment */
>        s4o.print("// RESOURCE ");
>        current_resource_name->accept(*this);
>        s4o.print("\n\n");
> -     
> +
>        s4o.print("extern unsigned long long common_ticktime__;\n\n");

>        s4o.print("#include \"accessor.h\"\n");
> @@ -1786,20 +1788,20 @@
>          delete vardecl;
>          s4o.print("\n");
>        }
> -     
> +
>        /* (A.3) POUs inclusion */
>        s4o.print("#include \"POUS.c\"\n\n");
> -     
> +
>        wanted_declaretype = declare_dt;
> -     
> +
>        /* (A.4) Resource programs declaration... */
>        symbol->task_configuration_list->accept(*this);
> -     
> +
>        /* (A.5) Resource programs declaration... */
>        symbol->program_configuration_list->accept(*this);
> -     
> +
>        s4o.print("\n");
> -     
> +
>        /* (B) resource initialisation function... */
>        /* (B.1) initialisation function name... */
>        s4o.print("void ");
> @@ -1811,7 +1813,7 @@
>        s4o.print("BOOL retain;\n");
>        s4o.print(s4o.indent_spaces);
>        s4o.print("retain = 0;\n");
> -     
> +
>        /* (B.2) Global variables initialisations... */
>        if (current_global_vars != NULL) {
>          s4o.print(s4o.indent_spaces);
> @@ -1823,18 +1825,18 @@
>          delete vardecl;
>        }
>        s4o.print("\n");
> -     
> +
>        wanted_declaretype = init_dt;
> -     
> +
>        /* (B.3) Tasks initialisations... */
>        symbol->task_configuration_list->accept(*this);
> -     
> +
>        /* (B.4) Resource programs initialisations... */
>        symbol->program_configuration_list->accept(*this);
> -     
> +
>        s4o.indent_left();
>        s4o.print("}\n\n");
> -     
> +
>        /* (C) Resource run function... */
>        /* (C.1) Run function name... */
>        s4o.print("void ");
> @@ -1842,25 +1844,25 @@
>        s4o.print(FB_RUN_SUFFIX);
>        s4o.print("(unsigned long tick) {\n");
>        s4o.indent_right();
> -     
> +
>        wanted_declaretype = run_dt;
> -     
> +
>        /* (C.2) Task management... */
>        symbol->task_configuration_list->accept(*this);
> -     
> +
>        /* (C.3) Program run declaration... */
>        symbol->program_configuration_list->accept(*this);
> -     
> +
>        s4o.indent_left();
>        s4o.print("}\n\n");
> -     
> +
>        if (single_resource) {
>          delete current_resource_name;
>          current_resource_name = NULL;
>        }
>        return NULL;
>      }
> -   
> +
>  /*  PROGRAM [RETAIN | NON_RETAIN] program_name [WITH task_name] ':' program_type_name ['(' prog_conf_elements ')'] */
>  //SYM_REF6(program_configuration_c, retain_option, program_name, task_name, program_type_name, prog_conf_elements, unused)
>      void *visit(program_configuration_c *symbol) {
> @@ -1891,7 +1893,7 @@
>            print_retain();
>            s4o.print(");\n");
>            break;
> -        case run_dt:
> +        case run_dt:
>            { identifier_c *tmp_id = dynamic_cast<identifier_c*>(symbol->program_name);
>              if (NULL == tmp_id) ERROR;
>              current_program_name = tmp_id->value;
> @@ -1901,24 +1903,24 @@
>              s4o.print("if (");
>              symbol->task_name->accept(*this);
>              s4o.print(") {\n");
> -            s4o.indent_right();
> +            s4o.indent_right();
>            }
> -       
> +
>            wanted_assigntype = assign_at;
>            if (symbol->prog_conf_elements != NULL)
>              symbol->prog_conf_elements->accept(*this);
> -         
> +
>            s4o.print(s4o.indent_spaces);
>            symbol->program_type_name->accept(*this);
>            s4o.print(FB_FUNCTION_SUFFIX);
>            s4o.print("(&");
>            symbol->program_name->accept(*this);
>            s4o.print(");\n");
> -         
> +
>            wanted_assigntype = send_at;
>            if (symbol->prog_conf_elements != NULL)
>              symbol->prog_conf_elements->accept(*this);
> -         
> +
>            if (symbol->task_name != NULL) {
>              s4o.indent_left();
>              s4o.print(s4o.indent_spaces + "}\n");
> @@ -1929,7 +1931,7 @@
>        }
>        return NULL;
>      }
> -   
> +
>  /*  TASK task_name task_initialization */
>  //SYM_REF2(task_configuration_c, task_name, task_initialization)
>      void *visit(task_configuration_c *symbol) {
> @@ -1956,7 +1958,7 @@
>        current_task_name = NULL;
>        return NULL;
>      }
> -   
> +
>  /*  '(' [SINGLE ASSIGN data_source ','] [INTERVAL ASSIGN data_source ','] PRIORITY ASSIGN integer ')' */
>  //SYM_REF4(task_initialization_c, single_data_source, interval_data_source, priority_data_source, unused)
>      void *visit(task_initialization_c *symbol) {
> @@ -2031,7 +2033,7 @@
>                else
>                  s4o.print("1");
>              }
> -            else
> +            else
>                s4o.print("1");
>            }
>            s4o.print(";\n");
> @@ -2059,7 +2061,7 @@
>          }
>          else
>            vartype = search_resource_instance->get_vartype(current_var_reference);
> -       
> +
>          s4o.print(s4o.indent_spaces + "{extern ");
>          var_decl->accept(*this);
>          s4o.print(" *");
> @@ -2094,7 +2096,7 @@
>          }
>          else
>            vartype = search_resource_instance->get_vartype(current_var_reference);
> -       
> +
>          s4o.print(s4o.indent_spaces + "{extern ");
>          var_decl->accept(*this);
>          s4o.print(" *");
> @@ -2131,7 +2133,7 @@
>  #define BACKUP_   "_backup__"

>  /* class to generate the forward declaration of the XXXX_backup() and XXXX_restore()
> - * functions that will later (in the generated C source code) be defined
> + * functions that will later (in the generated C source code) be defined
>   * to backup/restore the global state of each RESOURCE in the source code being compiled.
>   * The XXXX is actually the resource name!
>   */
> @@ -2139,27 +2141,27 @@
>    public:
>      generate_c_backup_resource_decl_c(stage4out_c *s4o_ptr)
>        : generate_c_base_and_typeid_c(s4o_ptr) {};
> -     
> +
>      void *visit(resource_declaration_c *symbol) {
>        s4o.print(s4o.indent_spaces);
>        s4o.print("void ");
>        symbol->resource_name->accept(*this);
> -      s4o.print("_backup__" "(void **buffer, int *maxsize);\n");     
> +      s4o.print("_backup__" "(void **buffer, int *maxsize);\n");
>        s4o.print(s4o.indent_spaces);
>        s4o.print("void ");
>        symbol->resource_name->accept(*this);
> -      s4o.print("_restore__" "(void **buffer, int *maxsize);\n");     
> +      s4o.print("_restore__" "(void **buffer, int *maxsize);\n");
>        return NULL;
>      }
> -   
> -   
> +
> +
>      void *visit(single_resource_declaration_c *symbol) {
>        /* __Must__ not insert any code! */
>        /* sinlge resources will not create a specific function for the resource */
>        /* backup and restore opertions will be inserted together with the configuration! */
>        return NULL;
>      }
> -   
> +
>  };


> @@ -2174,7 +2176,7 @@
>    s4o.indent_right();
>    // Don't save/restore the __CURRENT_TIME variable, as 'plc controller' has easy access to it
>    // and can therefore do the save/restore by itself.
> -//s4o.print(s4o.indent_spaces);
> +//s4o.print(s4o.indent_spaces);
>  //s4o.print(operation);
>  //s4o.print("(&__CURRENT_TIME, sizeof(__CURRENT_TIME), buffer, maxsize);\n");
>    s4o.print(s4o.indent_spaces);
> @@ -2202,7 +2204,7 @@
>    s4o.print(s4o.indent_spaces); s4o.print("#undef " DECLARE_GLOBAL_LOCATION "\n");
>    s4o.print(s4o.indent_spaces); s4o.print("#undef " DECLARE_GLOBAL_LOCATED  "\n");
>    s4o.indent_left();
> -  s4o.print("}\n");     
> +  s4o.print("}\n");
>  }


> @@ -2214,29 +2216,29 @@
>   * function generated for the configuration in which the resource is embedded
>   */
>  class generate_c_backup_resource_c: public generate_c_base_and_typeid_c {
> -  public:   
> +  public:
>      const char *operation;
> -   
> +
>      generate_c_backup_resource_c(stage4out_c *s4o_ptr)
>        : generate_c_base_and_typeid_c(s4o_ptr) {
>        operation = NULL;
>      };

> - 
> +
>      virtual ~generate_c_backup_resource_c(void) {}

> -   
> +
>  private:
>      void print_forward_declarations(void) {
>        s4o.print("\n\n\n");
> - 
> +
>        s4o.print("void ");
>        s4o.print("_backup__");
>        s4o.print("(void *varptr, int varsize, void **buffer, int *maxsize);\n");
>        s4o.print("void ");
>        s4o.print("_restore__");
>        s4o.print("(void *varptr, int varsize, void **buffer, int *maxsize);\n");
> - 
> +
>        s4o.print("\n\n\n");
>        s4o.print("#undef " DECLARE_GLOBAL          "\n");
>        s4o.print("#undef " DECLARE_GLOBAL_FB       "\n");
> @@ -2250,8 +2252,8 @@
>      /********************/
>      void *visit(enable_code_generation_pragma_c * symbol)   {s4o.enable_output(); return NULL;}
>      void *visit(disable_code_generation_pragma_c * symbol)  {s4o.disable_output();return NULL;}
> -       
> -       
> +
> +
>      /********************************/
>      /* B 1.7 Configuration elements */
>      /********************************/
> @@ -2259,24 +2261,24 @@
>        char *resource_name = strdup(symbol->resource_name->token->value);
>        /* convert to upper case */
>        for (char *c = resource_name; *c != '\0'; *c = toupper(*c), c++);
> -     
> +
>        generate_c_vardecl_c vardecl = generate_c_vardecl_c(&s4o,
>                                           generate_c_vardecl_c::local_vf,
>                                           generate_c_vardecl_c::global_vt,
>                                           symbol->resource_name);
> -     
> +
>        print_forward_declarations();
> -     
> +
>        print_backup_restore_function_beg(s4o, resource_name, "_backup__");
> -      if (symbol->global_var_declarations != NULL)   
> +      if (symbol->global_var_declarations != NULL)
>          vardecl.print(symbol->global_var_declarations);
>        if (symbol->resource_declaration != NULL) {
>          operation = "_backup__";
>          symbol->resource_declaration->accept(*this);  // will call visit(single_resource_declaration_c *)
>          operation = NULL;
>        }
> -      print_backup_restore_function_end(s4o);     
> -     
> +      print_backup_restore_function_end(s4o);
> +
>        print_backup_restore_function_beg(s4o, resource_name, "_restore__");
>        if (symbol->global_var_declarations != NULL)
>          vardecl.print(symbol->global_var_declarations);
> @@ -2285,18 +2287,18 @@
>          symbol->resource_declaration->accept(*this);  // will call visit(single_resource_declaration_c *)
>          operation = NULL;
>        }
> -      print_backup_restore_function_end(s4o);     
> +      print_backup_restore_function_end(s4o);

>        return NULL;
>      }
> -   
> +
>      void *visit(single_resource_declaration_c *symbol) {
>        /* Must store the declared/instatiated PROGRAMS */
>        if (symbol->program_configuration_list != NULL)
>          symbol->program_configuration_list->accept(*this);
>        return NULL;
>      }
> -   
> +
>      /*  PROGRAM [RETAIN | NON_RETAIN] program_name [WITH task_name] ':' program_type_name ['(' prog_conf_elements ')'] */
>      // SYM_REF5(program_configuration_c, retain_option, program_name, task_name, program_type_name, prog_conf_elements)
>      void *visit(program_configuration_c *symbol) {
> @@ -2304,7 +2306,7 @@
>        // _xxxxxx__(&program_name, sizeof(program_name), buffer, maxsize);
>        s4o.print(s4o.indent_spaces);
>        s4o.print(operation); // call _restore__() or _backup__()
> -      s4o.print("(&");
> +      s4o.print("(&");
>        symbol->program_name->accept(*this);
>        s4o.print(", sizeof(");
>        symbol->program_name->accept(*this);
> @@ -2321,20 +2323,20 @@
>   * configuration, and call the backup/restore functions of each embedded resource to do
>   * the same for the global variables declared inside each resource.
>   *
> - *   The matiec compiler will now generate two additional functions which
> + *   The matiec compiler will now generate two additional functions which
>   *   will backup and restore the PLC internal state to a void *buffer.
>   *       config_backup__(void **buffer, int *maxsize)
>   *       config_restore__(void **buffer, int *maxsize)
>   *
> - *   Both functions will backup/restore the internal state from the memory
> + *   Both functions will backup/restore the internal state from the memory
>   *   pointed to by *buffer, up to a maximum of *maxsize bytes.
> - *   Both functions will return with buffer pointing to the first unused
> - *   byte in the buffer, and maxsize with the number of remaining bytes. If
> - *   the buffer is not sufficient to store all the internal state, maxsize
> - *   will return with a negative number, equal to the number of missing
> + *   Both functions will return with buffer pointing to the first unused
> + *   byte in the buffer, and maxsize with the number of remaining bytes. If
> + *   the buffer is not sufficient to store all the internal state, maxsize
> + *   will return with a negative number, equal to the number of missing
>   *   bytes.
>   *
> - *   In other words, to know the exact size of the buffer required to store
> + *   In other words, to know the exact size of the buffer required to store
>   *   the PLC internal state, malloc() that memory, and do the backup:
>   *          int maxsize = 0;
>   *          config_backup__(NULL, &maxsize);
> @@ -2355,15 +2357,15 @@

>      virtual ~generate_c_backup_config_c(void) {}

> -   
> +
>    public:
>      /********************/
>      /* 2.1.6 - Pragmas  */
>      /********************/
>      void *visit(enable_code_generation_pragma_c * symbol)   {s4o.enable_output(); return NULL;}
>      void *visit(disable_code_generation_pragma_c * symbol)  {s4o.disable_output();return NULL;}
> -       
> -       
> +
> +
>      /********************************/
>      /* B 1.7 Configuration elements */
>      /********************************/
> @@ -2371,24 +2373,24 @@
>      SYM_REF6(configuration_declaration_c, configuration_name, global_var_declarations, resource_declarations, access_declarations, instance_specific_initializations, unused)
>      */
>      void *visit(configuration_declaration_c *symbol) {
> -     
> +
>        s4o.print("\n\n\n");
> -     
> +
>        s4o.print("void ");
>        s4o.print("_backup__");
>        s4o.print("(void *varptr, int varsize, void **buffer, int *maxsize) {\n");
>        s4o.print("  if (varsize <= *maxsize) {memmove(*buffer, varptr, varsize); *buffer += varsize;}\n");
>        s4o.print("  *maxsize -= varsize;\n");
>        s4o.print("}\n");
> -     
> +
>        s4o.print("void ");
>        s4o.print("_restore__");
>        s4o.print("(void *varptr, int varsize, void **buffer, int *maxsize) {\n");
>        s4o.print("  if (varsize <= *maxsize) {memmove(varptr, *buffer, varsize); *buffer += varsize;}\n");
>        s4o.print("  *maxsize -= varsize;\n");
>        s4o.print("}\n");
> -     
> -     
> +
> +
>        generate_c_vardecl_c vardecl = generate_c_vardecl_c(&s4o,
>                                           generate_c_vardecl_c::local_vf,
>                                           generate_c_vardecl_c::global_vt,
> @@ -2399,37 +2401,37 @@
>        s4o.print("#undef " DECLARE_GLOBAL_FB       "\n");
>        s4o.print("#undef " DECLARE_GLOBAL_LOCATION "\n");
>        s4o.print("#undef " DECLARE_GLOBAL_LOCATED  "\n");
> -     
> +
>        generate_c_backup_resource_decl_c declare_functions = generate_c_backup_resource_decl_c(&s4o);
>        symbol->resource_declarations->accept(declare_functions);
> -     
> +
>        print_backup_restore_function_beg(s4o, "config", "_backup__");
>        vardecl.print(symbol);
>        s4o.print("\n");
>        func_to_call = "_backup__";
>        symbol->resource_declarations->accept(*this);  // will call resource_declaration_list_c or single_resource_declaration_c
>        func_to_call = NULL;
> -      print_backup_restore_function_end(s4o);     
> -   
> +      print_backup_restore_function_end(s4o);
> +
>        print_backup_restore_function_beg(s4o, "config", "_restore__");
>        vardecl.print(symbol);
>        s4o.print("\n");
>        func_to_call = "_restore__";
>        symbol->resource_declarations->accept(*this);  // will call resource_declaration_list_c or single_resource_declaration_c
>        func_to_call = NULL;
> -      print_backup_restore_function_end(s4o);     
> -     
> +      print_backup_restore_function_end(s4o);
> +
>        return NULL;
>      }
> -   
> +
>      void *visit(resource_declaration_c *symbol) {
>        s4o.print(s4o.indent_spaces);
>        symbol->resource_name->accept(*this);
>        s4o.print(func_to_call);
> -      s4o.print("(buffer, maxsize);\n");     
> +      s4o.print("(buffer, maxsize);\n");
>        return NULL;
>      }
> -   
> +
>      void *visit(single_resource_declaration_c *symbol) {
>        /* If the configuration does not have any resources, we must store/restore the declared program instances
>         * inside the backup() restore() functions created for the configuration.
> @@ -2460,22 +2462,22 @@
>      stage4out_c             pous_incl_s4o;
>      stage4out_c     located_variables_s4o;
>      stage4out_c             variables_s4o;
> -   
> +
>      generate_c_typedecl_c          generate_c_typedecl;
>      generate_c_implicit_typedecl_c generate_c_implicit_typedecl;
>      generate_c_pous_c              generate_c_pous;
> -   
> +
>      symbol_c   *current_configuration;

>      const char *current_name;
>      const char *current_builddir;

>      bool        allow_output;
> -   
> +
>      unsigned long long common_ticktime;

>    public:
> -    generate_c_c(stage4out_c *s4o_ptr, const char *builddir):
> +    generate_c_c(stage4out_c *s4o_ptr, const char *builddir):
>              s4o(*s4o_ptr),
>              pous_s4o(builddir, "POUS", "c"),
>              pous_incl_s4o(builddir, "POUS", "h"),
> @@ -2488,7 +2490,7 @@
>        current_configuration = NULL;
>        allow_output = true;
>      }
> -           
> +
>      ~generate_c_c(void) {}


> @@ -2497,24 +2499,24 @@
>  /* 2.1.6 - Pragmas  */
>  /********************/
>      void *visit(enable_code_generation_pragma_c * symbol)  {
> -      s4o                  .enable_output(); 
> -      pous_s4o             .enable_output(); 
> -      pous_incl_s4o        .enable_output(); 
> -      located_variables_s4o.enable_output(); 
> -      variables_s4o        .enable_output(); 
> -      allow_output = true;     
> +      s4o                  .enable_output();
> +      pous_s4o             .enable_output();
> +      pous_incl_s4o        .enable_output();
> +      located_variables_s4o.enable_output();
> +      variables_s4o        .enable_output();
> +      allow_output = true;
>        return NULL;
>      }
> -   
> +
>      void *visit(disable_code_generation_pragma_c * symbol)  {
> -      s4o                  .disable_output(); 
> -      pous_s4o             .disable_output(); 
> -      pous_incl_s4o        .disable_output(); 
> -      located_variables_s4o.disable_output(); 
> -      variables_s4o        .disable_output(); 
> -      allow_output = false;     
> +      s4o                  .disable_output();
> +      pous_s4o             .disable_output();
> +      pous_incl_s4o        .disable_output();
> +      located_variables_s4o.disable_output();
> +      variables_s4o        .disable_output();
> +      allow_output = false;
>        return NULL;
> -    }
> +    }


>  /***************************/
> @@ -2522,7 +2524,7 @@
>  /***************************/
>      void *visit(library_c *symbol) {
>        pous_incl_s4o.print("#ifndef __POUS_H\n#define __POUS_H\n\n");
> -     
> +
>        if (runtime_options.disable_implicit_en_eno) {
>          // If we are not generating the EN and ENO parameters for functions and FB,
>          //   then make sure we use the standard library version compiled without these parameters too!
> @@ -2530,7 +2532,7 @@
>          pous_incl_s4o.print("#define DISABLE_EN_ENO_PARAMETERS\n");
>          pous_incl_s4o.print("#endif\n");
>        }
> -     
> +
>        pous_incl_s4o.print("#include \"accessor.h\"\n#include \"iec_std_lib.h\"\n\n");

>        for(int i = 0; i < symbol->n; i++) {
> @@ -2538,7 +2540,7 @@
>        }

>        pous_incl_s4o.print("#endif //__POUS_H\n");
> -     
> +
>        generate_var_list_c generate_var_list(&variables_s4o, symbol);
>        generate_var_list.generate_programs(symbol);
>        generate_var_list.generate_variables(symbol);
> @@ -2561,7 +2563,7 @@
>      /* In the derived datatype and POUs declarations, the names are stored as identfier_c, so the following visitors are not required! */
>      void *visit(derived_datatype_identifier_c *symbol) {ERROR; return NULL;}
>      void *visit(         poutype_identifier_c *symbol) {ERROR; return NULL;}
> -   
> +

>  /********************************/
>  /* B 1.3.3 - Derived data types */
> @@ -2613,12 +2615,12 @@

>  /***********************/
>  /* B 1.5.1 - Functions */
> -/***********************/     
> +/***********************/
>      void *visit(function_declaration_c *symbol) {
>        handle_pou(handle_function,symbol->derived_function_name)
>        return NULL;
>      }
> -   
> +
>  /*****************************/
>  /* B 1.5.2 - Function Blocks */
>  /*****************************/
> @@ -2626,15 +2628,15 @@
>        handle_pou(handle_function_block,symbol->fblock_name)
>        return NULL;
>      }
> -   
> +
>  /**********************/
>  /* B 1.5.3 - Programs */
> -/**********************/   
> +/**********************/
>      void *visit(program_declaration_c *symbol) {
>        handle_pou(handle_program,symbol->program_type_name)
>        return NULL;
>      }
> -   
> +

>  /********************************/
>  /* B 1.7 Configuration elements */
> @@ -2662,7 +2664,7 @@
>          }

>          symbol->configuration_name->accept(*this);
> -       
> +
>          stage4out_c config_s4o(current_builddir, current_name, "c");
>          stage4out_c config_incl_s4o(current_builddir, current_name, "h");
>          generate_c_config_c generate_c_config(&config_s4o, &config_incl_s4o);
> @@ -2707,7 +2709,7 @@
>        symbol->accept(generate_c_resources);
>        return NULL;
>      }
> -   
> +
>  };

>  /***********************************************************************/

> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot

> _______________________________________________
> Beremiz-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/beremiz-devel


--
Best regards,
Andrey Skvortsov

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Beremiz-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beremiz-devel



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Beremiz-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beremiz-devel

matiec_greatest_tick_count_fix_rev2.patch (1K) Download Attachment