msousa@597: /* msousa@597: * matiec - a compiler for the programming languages defined in IEC 61131-3 msousa@597: * Copyright (C) 2003-2011 Mario de Sousa (msousa@fe.up.pt) msousa@597: * Copyright (C) 2007-2011 Laurent Bessard and Edouard Tisserant msousa@597: * msousa@597: * This program is free software: you can redistribute it and/or modify msousa@597: * it under the terms of the GNU General Public License as published by msousa@597: * the Free Software Foundation, either version 3 of the License, or msousa@597: * (at your option) any later version. msousa@597: * msousa@597: * This program is distributed in the hope that it will be useful, msousa@597: * but WITHOUT ANY WARRANTY; without even the implied warranty of msousa@597: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the msousa@597: * GNU General Public License for more details. msousa@597: * msousa@597: * You should have received a copy of the GNU General Public License msousa@597: * along with this program. If not, see . msousa@597: * msousa@597: * msousa@597: * This code is made available on the understanding that it will not be msousa@597: * used in safety-critical situations without a full and competent review. msousa@597: */ msousa@597: msousa@597: /* msousa@597: * An IEC 61131-3 compiler. msousa@597: * msousa@597: * Based on the msousa@597: * FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10) msousa@597: * msousa@597: */ msousa@597: msousa@597: msousa@597: msousa@597: #ifndef _MAIN_HH msousa@597: #define _MAIN_HH msousa@597: msousa@604: msousa@604: /* Get the definition of INT16_MAX, INT16_MIN, UINT64_MAX, INT64_MAX, INT64_MIN, ... */ msousa@604: msousa@604: #define __STDC_LIMIT_MACROS /* required when including from C++ source code. */ msousa@604: #include msousa@604: msousa@604: #ifndef UINT64_MAX msousa@604: #define UINT64_MAX (std::numeric_limits< uint64_t >::max()) msousa@604: #endif msousa@604: #ifndef INT64_MAX msousa@604: #define INT64_MAX (std::numeric_limits< int64_t >::max()) msousa@604: #endif msousa@604: #ifndef INT64_MIN msousa@604: #define INT64_MIN (std::numeric_limits< int64_t >::min()) msousa@604: #endif msousa@604: msousa@604: #if (real64_t == float) msousa@604: #define HUGE_VAL64 HUGE_VALF msousa@604: #elif (real64_t == double) msousa@604: #define HUGE_VAL64 HUGE_VAL msousa@604: #elif (real64_t == long_double) msousa@604: #define HUGE_VAL64 HUGE_VALL msousa@604: #else msousa@604: #error Could not determine which data type is being used for real64_t (defined in absyntax.hh). Aborting! msousa@604: #endif msousa@604: msousa@604: msousa@604: msousa@604: msousa@597: /* Function used throughout the code --> used to report failed assertions (i.e. internal compiler errors)! */ msousa@604: #include /* required for NULL */ msousa@604: msousa@597: #define ERROR error_exit(__FILE__,__LINE__) msousa@597: #define ERROR_MSG(msg, ...) error_exit(__FILE__,__LINE__, msg) msousa@597: // #define ERROR_MSG(msg, ...) error_exit(__FILE__,__LINE__, msg, __VA_ARGS__) msousa@597: msousa@597: extern void error_exit(const char *file_name, int line_no, const char *errmsg = NULL, ...); msousa@597: msousa@597: msousa@597: msousa@597: msousa@597: #endif // #ifndef _MAIN_HH