main.hh
author Mario de Sousa <msousa@fe.up.pt>
Wed, 18 Jul 2012 16:56:36 +0100
changeset 604 2989051a0a64
parent 597 7326a0658104
child 607 be9ba3531afb
permissions -rw-r--r--
Fixing includes to define INTxx_MAX etc...
597
7326a0658104 Add file missing from previous commit.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
     1
/*
7326a0658104 Add file missing from previous commit.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
     2
 *  matiec - a compiler for the programming languages defined in IEC 61131-3
7326a0658104 Add file missing from previous commit.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
     3
 *  Copyright (C) 2003-2011  Mario de Sousa (msousa@fe.up.pt)
7326a0658104 Add file missing from previous commit.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
     4
 *  Copyright (C) 2007-2011  Laurent Bessard and Edouard Tisserant
7326a0658104 Add file missing from previous commit.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
     5
 *
7326a0658104 Add file missing from previous commit.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
     6
 *  This program is free software: you can redistribute it and/or modify
7326a0658104 Add file missing from previous commit.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
     7
 *  it under the terms of the GNU General Public License as published by
7326a0658104 Add file missing from previous commit.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
     8
 *  the Free Software Foundation, either version 3 of the License, or
7326a0658104 Add file missing from previous commit.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
     9
 *  (at your option) any later version.
7326a0658104 Add file missing from previous commit.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    10
 *
7326a0658104 Add file missing from previous commit.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    11
 *  This program is distributed in the hope that it will be useful,
7326a0658104 Add file missing from previous commit.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    12
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
7326a0658104 Add file missing from previous commit.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    13
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
7326a0658104 Add file missing from previous commit.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    14
 *  GNU General Public License for more details.
7326a0658104 Add file missing from previous commit.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    15
 *
7326a0658104 Add file missing from previous commit.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    16
 *  You should have received a copy of the GNU General Public License
7326a0658104 Add file missing from previous commit.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    17
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
7326a0658104 Add file missing from previous commit.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    18
 *
7326a0658104 Add file missing from previous commit.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    19
 *
7326a0658104 Add file missing from previous commit.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    20
 * This code is made available on the understanding that it will not be
7326a0658104 Add file missing from previous commit.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    21
 * used in safety-critical situations without a full and competent review.
7326a0658104 Add file missing from previous commit.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    22
 */
7326a0658104 Add file missing from previous commit.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    23
7326a0658104 Add file missing from previous commit.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    24
/*
7326a0658104 Add file missing from previous commit.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    25
 * An IEC 61131-3 compiler.
7326a0658104 Add file missing from previous commit.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    26
 *
7326a0658104 Add file missing from previous commit.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    27
 * Based on the
7326a0658104 Add file missing from previous commit.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    28
 * FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
7326a0658104 Add file missing from previous commit.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    29
 *
7326a0658104 Add file missing from previous commit.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    30
 */
7326a0658104 Add file missing from previous commit.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    31
7326a0658104 Add file missing from previous commit.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    32
7326a0658104 Add file missing from previous commit.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    33
7326a0658104 Add file missing from previous commit.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    34
#ifndef _MAIN_HH
7326a0658104 Add file missing from previous commit.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    35
#define _MAIN_HH
7326a0658104 Add file missing from previous commit.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    36
604
2989051a0a64 Fixing includes to define INTxx_MAX etc...
Mario de Sousa <msousa@fe.up.pt>
parents: 597
diff changeset
    37
2989051a0a64 Fixing includes to define INTxx_MAX etc...
Mario de Sousa <msousa@fe.up.pt>
parents: 597
diff changeset
    38
 /* Get the definition of INT16_MAX, INT16_MIN, UINT64_MAX, INT64_MAX, INT64_MIN, ... */
2989051a0a64 Fixing includes to define INTxx_MAX etc...
Mario de Sousa <msousa@fe.up.pt>
parents: 597
diff changeset
    39
2989051a0a64 Fixing includes to define INTxx_MAX etc...
Mario de Sousa <msousa@fe.up.pt>
parents: 597
diff changeset
    40
#define __STDC_LIMIT_MACROS /* required when including from C++ source code. */
2989051a0a64 Fixing includes to define INTxx_MAX etc...
Mario de Sousa <msousa@fe.up.pt>
parents: 597
diff changeset
    41
#include <stdint.h>         
2989051a0a64 Fixing includes to define INTxx_MAX etc...
Mario de Sousa <msousa@fe.up.pt>
parents: 597
diff changeset
    42
2989051a0a64 Fixing includes to define INTxx_MAX etc...
Mario de Sousa <msousa@fe.up.pt>
parents: 597
diff changeset
    43
#ifndef   UINT64_MAX 
2989051a0a64 Fixing includes to define INTxx_MAX etc...
Mario de Sousa <msousa@fe.up.pt>
parents: 597
diff changeset
    44
  #define UINT64_MAX (std::numeric_limits< uint64_t >::max())
2989051a0a64 Fixing includes to define INTxx_MAX etc...
Mario de Sousa <msousa@fe.up.pt>
parents: 597
diff changeset
    45
#endif
2989051a0a64 Fixing includes to define INTxx_MAX etc...
Mario de Sousa <msousa@fe.up.pt>
parents: 597
diff changeset
    46
#ifndef    INT64_MAX 
2989051a0a64 Fixing includes to define INTxx_MAX etc...
Mario de Sousa <msousa@fe.up.pt>
parents: 597
diff changeset
    47
  #define  INT64_MAX (std::numeric_limits<  int64_t >::max())
2989051a0a64 Fixing includes to define INTxx_MAX etc...
Mario de Sousa <msousa@fe.up.pt>
parents: 597
diff changeset
    48
#endif
2989051a0a64 Fixing includes to define INTxx_MAX etc...
Mario de Sousa <msousa@fe.up.pt>
parents: 597
diff changeset
    49
#ifndef    INT64_MIN
2989051a0a64 Fixing includes to define INTxx_MAX etc...
Mario de Sousa <msousa@fe.up.pt>
parents: 597
diff changeset
    50
  #define  INT64_MIN (std::numeric_limits<  int64_t >::min()) 
2989051a0a64 Fixing includes to define INTxx_MAX etc...
Mario de Sousa <msousa@fe.up.pt>
parents: 597
diff changeset
    51
#endif
2989051a0a64 Fixing includes to define INTxx_MAX etc...
Mario de Sousa <msousa@fe.up.pt>
parents: 597
diff changeset
    52
2989051a0a64 Fixing includes to define INTxx_MAX etc...
Mario de Sousa <msousa@fe.up.pt>
parents: 597
diff changeset
    53
#if    (real64_t  == float)
2989051a0a64 Fixing includes to define INTxx_MAX etc...
Mario de Sousa <msousa@fe.up.pt>
parents: 597
diff changeset
    54
  #define HUGE_VAL64  HUGE_VALF
2989051a0a64 Fixing includes to define INTxx_MAX etc...
Mario de Sousa <msousa@fe.up.pt>
parents: 597
diff changeset
    55
#elif  (real64_t  == double)
2989051a0a64 Fixing includes to define INTxx_MAX etc...
Mario de Sousa <msousa@fe.up.pt>
parents: 597
diff changeset
    56
  #define HUGE_VAL64  HUGE_VAL
2989051a0a64 Fixing includes to define INTxx_MAX etc...
Mario de Sousa <msousa@fe.up.pt>
parents: 597
diff changeset
    57
#elif  (real64_t  == long_double)
2989051a0a64 Fixing includes to define INTxx_MAX etc...
Mario de Sousa <msousa@fe.up.pt>
parents: 597
diff changeset
    58
  #define HUGE_VAL64  HUGE_VALL
2989051a0a64 Fixing includes to define INTxx_MAX etc...
Mario de Sousa <msousa@fe.up.pt>
parents: 597
diff changeset
    59
#else 
2989051a0a64 Fixing includes to define INTxx_MAX etc...
Mario de Sousa <msousa@fe.up.pt>
parents: 597
diff changeset
    60
  #error Could not determine which data type is being used for real64_t (defined in absyntax.hh). Aborting!
2989051a0a64 Fixing includes to define INTxx_MAX etc...
Mario de Sousa <msousa@fe.up.pt>
parents: 597
diff changeset
    61
#endif
2989051a0a64 Fixing includes to define INTxx_MAX etc...
Mario de Sousa <msousa@fe.up.pt>
parents: 597
diff changeset
    62
2989051a0a64 Fixing includes to define INTxx_MAX etc...
Mario de Sousa <msousa@fe.up.pt>
parents: 597
diff changeset
    63
2989051a0a64 Fixing includes to define INTxx_MAX etc...
Mario de Sousa <msousa@fe.up.pt>
parents: 597
diff changeset
    64
2989051a0a64 Fixing includes to define INTxx_MAX etc...
Mario de Sousa <msousa@fe.up.pt>
parents: 597
diff changeset
    65
597
7326a0658104 Add file missing from previous commit.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    66
 /* Function used throughout the code --> used to report failed assertions (i.e. internal compiler errors)! */
604
2989051a0a64 Fixing includes to define INTxx_MAX etc...
Mario de Sousa <msousa@fe.up.pt>
parents: 597
diff changeset
    67
#include <stddef.h>  /* required for NULL */
2989051a0a64 Fixing includes to define INTxx_MAX etc...
Mario de Sousa <msousa@fe.up.pt>
parents: 597
diff changeset
    68
 
597
7326a0658104 Add file missing from previous commit.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    69
#define ERROR               error_exit(__FILE__,__LINE__)
7326a0658104 Add file missing from previous commit.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    70
#define ERROR_MSG(msg, ...) error_exit(__FILE__,__LINE__, msg)
7326a0658104 Add file missing from previous commit.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    71
// #define ERROR_MSG(msg, ...) error_exit(__FILE__,__LINE__, msg, __VA_ARGS__)
7326a0658104 Add file missing from previous commit.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    72
7326a0658104 Add file missing from previous commit.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    73
extern void error_exit(const char *file_name, int line_no, const char *errmsg = NULL, ...);
7326a0658104 Add file missing from previous commit.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    74
7326a0658104 Add file missing from previous commit.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    75
7326a0658104 Add file missing from previous commit.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    76
7326a0658104 Add file missing from previous commit.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    77
7326a0658104 Add file missing from previous commit.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    78
#endif // #ifndef _MAIN_HH