author | Andrey Skvortsov <andrej.skvortzov@gmail.com> |
Tue, 28 Jun 2016 13:34:29 +0000 | |
branch | fix_compilation_warnings |
changeset 1009 | d7d3a0db7cc2 |
parent 980 | 9ed5aff159db |
child 1011 | 76175defb87b |
permissions | -rw-r--r-- |
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 |
|
946
c012a64dc2fa
Make the relaxed datatype model a runtime option (off by default)
mjsousa
parents:
890
diff
changeset
|
39 |
/* Compiler options, specified at runtime on the command line */ |
c012a64dc2fa
Make the relaxed datatype model a runtime option (off by default)
mjsousa
parents:
890
diff
changeset
|
40 |
|
c012a64dc2fa
Make the relaxed datatype model a runtime option (off by default)
mjsousa
parents:
890
diff
changeset
|
41 |
typedef struct { |
c012a64dc2fa
Make the relaxed datatype model a runtime option (off by default)
mjsousa
parents:
890
diff
changeset
|
42 |
/* options specific to stage1_2 */ |
956 | 43 |
bool pre_parsing; /* Support forward references (Run a pre-parsing phase before the defintive parsing phase that builds the AST) */ |
946
c012a64dc2fa
Make the relaxed datatype model a runtime option (off by default)
mjsousa
parents:
890
diff
changeset
|
44 |
bool safe_extensions; /* support SAFE_* datatypes defined in PLCOpen TC5 "Safety Software Technical Specification - Part 1" v1.0 */ |
c012a64dc2fa
Make the relaxed datatype model a runtime option (off by default)
mjsousa
parents:
890
diff
changeset
|
45 |
bool full_token_loc; /* error messages specify full token location */ |
c012a64dc2fa
Make the relaxed datatype model a runtime option (off by default)
mjsousa
parents:
890
diff
changeset
|
46 |
bool conversion_functions; /* Create a conversion function for derived datatype */ |
c012a64dc2fa
Make the relaxed datatype model a runtime option (off by default)
mjsousa
parents:
890
diff
changeset
|
47 |
bool nested_comments; /* Allow the use of nested comments. */ |
c012a64dc2fa
Make the relaxed datatype model a runtime option (off by default)
mjsousa
parents:
890
diff
changeset
|
48 |
bool ref_standard_extensions; /* Allow the use of REFerences (keywords REF_TO, REF, DREF, ^, NULL). */ |
c012a64dc2fa
Make the relaxed datatype model a runtime option (off by default)
mjsousa
parents:
890
diff
changeset
|
49 |
bool ref_nonstand_extensions; /* Allow the use of non-standard extensions to REF_TO datatypes: REF_TO ANY, and REF_TO in struct elements! */ |
980
9ed5aff159db
Make support for use of variables in array size declarations a command line option (off by default)
mjsousa
parents:
956
diff
changeset
|
50 |
bool nonliteral_in_array_size; /* Allow the use of constant non-literals when specifying size of arrays (ARRAY [1..max] OF INT) */ |
946
c012a64dc2fa
Make the relaxed datatype model a runtime option (off by default)
mjsousa
parents:
890
diff
changeset
|
51 |
const char *includedir; /* Include directory, where included files will be searched for... */ |
c012a64dc2fa
Make the relaxed datatype model a runtime option (off by default)
mjsousa
parents:
890
diff
changeset
|
52 |
|
c012a64dc2fa
Make the relaxed datatype model a runtime option (off by default)
mjsousa
parents:
890
diff
changeset
|
53 |
/* options specific to stage3 */ |
c012a64dc2fa
Make the relaxed datatype model a runtime option (off by default)
mjsousa
parents:
890
diff
changeset
|
54 |
bool relaxed_datatype_model; /* Use the relaxed datatype equivalence model, instead of the default strict equivalence model */ |
c012a64dc2fa
Make the relaxed datatype model a runtime option (off by default)
mjsousa
parents:
890
diff
changeset
|
55 |
} runtime_options_t; |
c012a64dc2fa
Make the relaxed datatype model a runtime option (off by default)
mjsousa
parents:
890
diff
changeset
|
56 |
|
c012a64dc2fa
Make the relaxed datatype model a runtime option (off by default)
mjsousa
parents:
890
diff
changeset
|
57 |
extern runtime_options_t runtime_options; |
c012a64dc2fa
Make the relaxed datatype model a runtime option (off by default)
mjsousa
parents:
890
diff
changeset
|
58 |
|
c012a64dc2fa
Make the relaxed datatype model a runtime option (off by default)
mjsousa
parents:
890
diff
changeset
|
59 |
|
c012a64dc2fa
Make the relaxed datatype model a runtime option (off by default)
mjsousa
parents:
890
diff
changeset
|
60 |
|
c012a64dc2fa
Make the relaxed datatype model a runtime option (off by default)
mjsousa
parents:
890
diff
changeset
|
61 |
|
c012a64dc2fa
Make the relaxed datatype model a runtime option (off by default)
mjsousa
parents:
890
diff
changeset
|
62 |
|
c012a64dc2fa
Make the relaxed datatype model a runtime option (off by default)
mjsousa
parents:
890
diff
changeset
|
63 |
|
597
7326a0658104
Add file missing from previous commit.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
64 |
/* 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
|
65 |
#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
|
66 |
|
597
7326a0658104
Add file missing from previous commit.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
67 |
#define ERROR error_exit(__FILE__,__LINE__) |
654
7421cb63defa
list_c: initial capacity. ERROR_MSG(msg,...) supports optional arguments now.
agraeper
parents:
645
diff
changeset
|
68 |
#define ERROR_MSG(msg, ...) error_exit(__FILE__,__LINE__, msg, ## __VA_ARGS__) |
597
7326a0658104
Add file missing from previous commit.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
69 |
|
7326a0658104
Add file missing from previous commit.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
70 |
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
|
71 |
|
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 |
|
7326a0658104
Add file missing from previous commit.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
74 |
|
607
be9ba3531afb
cleaning up code. Changing HUGE_VAL to INFINITY.
Mario de Sousa <msousa@fe.up.pt>
parents:
604
diff
changeset
|
75 |
/* Get the definition of INT16_MAX, INT16_MIN, UINT64_MAX, INT64_MAX, INT64_MIN, ... */ |
760 | 76 |
#ifndef __STDC_LIMIT_MACROS |
607
be9ba3531afb
cleaning up code. Changing HUGE_VAL to INFINITY.
Mario de Sousa <msousa@fe.up.pt>
parents:
604
diff
changeset
|
77 |
#define __STDC_LIMIT_MACROS /* required to have UINTxx_MAX defined when including stdint.h from C++ source code. */ |
760 | 78 |
#endif |
607
be9ba3531afb
cleaning up code. Changing HUGE_VAL to INFINITY.
Mario de Sousa <msousa@fe.up.pt>
parents:
604
diff
changeset
|
79 |
#include <stdint.h> |
be9ba3531afb
cleaning up code. Changing HUGE_VAL to INFINITY.
Mario de Sousa <msousa@fe.up.pt>
parents:
604
diff
changeset
|
80 |
#include <limits> |
be9ba3531afb
cleaning up code. Changing HUGE_VAL to INFINITY.
Mario de Sousa <msousa@fe.up.pt>
parents:
604
diff
changeset
|
81 |
|
be9ba3531afb
cleaning up code. Changing HUGE_VAL to INFINITY.
Mario de Sousa <msousa@fe.up.pt>
parents:
604
diff
changeset
|
82 |
#ifndef UINT64_MAX |
be9ba3531afb
cleaning up code. Changing HUGE_VAL to INFINITY.
Mario de Sousa <msousa@fe.up.pt>
parents:
604
diff
changeset
|
83 |
#define UINT64_MAX (std::numeric_limits< uint64_t >::max()) |
be9ba3531afb
cleaning up code. Changing HUGE_VAL to INFINITY.
Mario de Sousa <msousa@fe.up.pt>
parents:
604
diff
changeset
|
84 |
#endif |
be9ba3531afb
cleaning up code. Changing HUGE_VAL to INFINITY.
Mario de Sousa <msousa@fe.up.pt>
parents:
604
diff
changeset
|
85 |
#ifndef INT64_MAX |
be9ba3531afb
cleaning up code. Changing HUGE_VAL to INFINITY.
Mario de Sousa <msousa@fe.up.pt>
parents:
604
diff
changeset
|
86 |
#define INT64_MAX (std::numeric_limits< int64_t >::max()) |
be9ba3531afb
cleaning up code. Changing HUGE_VAL to INFINITY.
Mario de Sousa <msousa@fe.up.pt>
parents:
604
diff
changeset
|
87 |
#endif |
be9ba3531afb
cleaning up code. Changing HUGE_VAL to INFINITY.
Mario de Sousa <msousa@fe.up.pt>
parents:
604
diff
changeset
|
88 |
#ifndef INT64_MIN |
be9ba3531afb
cleaning up code. Changing HUGE_VAL to INFINITY.
Mario de Sousa <msousa@fe.up.pt>
parents:
604
diff
changeset
|
89 |
#define INT64_MIN (std::numeric_limits< int64_t >::min()) |
be9ba3531afb
cleaning up code. Changing HUGE_VAL to INFINITY.
Mario de Sousa <msousa@fe.up.pt>
parents:
604
diff
changeset
|
90 |
#endif |
be9ba3531afb
cleaning up code. Changing HUGE_VAL to INFINITY.
Mario de Sousa <msousa@fe.up.pt>
parents:
604
diff
changeset
|
91 |
|
be9ba3531afb
cleaning up code. Changing HUGE_VAL to INFINITY.
Mario de Sousa <msousa@fe.up.pt>
parents:
604
diff
changeset
|
92 |
|
be9ba3531afb
cleaning up code. Changing HUGE_VAL to INFINITY.
Mario de Sousa <msousa@fe.up.pt>
parents:
604
diff
changeset
|
93 |
|
be9ba3531afb
cleaning up code. Changing HUGE_VAL to INFINITY.
Mario de Sousa <msousa@fe.up.pt>
parents:
604
diff
changeset
|
94 |
/* Determine, for the current platform, which datas types (float, double or long double) use 64 and 32 bits. */ |
be9ba3531afb
cleaning up code. Changing HUGE_VAL to INFINITY.
Mario de Sousa <msousa@fe.up.pt>
parents:
604
diff
changeset
|
95 |
/* NOTE: We cant use sizeof() in pre-processor directives, so we have to do it another way... */ |
be9ba3531afb
cleaning up code. Changing HUGE_VAL to INFINITY.
Mario de Sousa <msousa@fe.up.pt>
parents:
604
diff
changeset
|
96 |
/* CURIOSITY: We can use sizeof() and offsetof() inside static_assert() but: |
be9ba3531afb
cleaning up code. Changing HUGE_VAL to INFINITY.
Mario de Sousa <msousa@fe.up.pt>
parents:
604
diff
changeset
|
97 |
* - this only allows us to make assertions, and not #define new macros |
be9ba3531afb
cleaning up code. Changing HUGE_VAL to INFINITY.
Mario de Sousa <msousa@fe.up.pt>
parents:
604
diff
changeset
|
98 |
* - is only available in the C standard [ISO/IEC 9899:2011] and the C++ 0X draft standard [Becker 2008]. It is not available in C99. |
be9ba3531afb
cleaning up code. Changing HUGE_VAL to INFINITY.
Mario de Sousa <msousa@fe.up.pt>
parents:
604
diff
changeset
|
99 |
* https://www.securecoding.cert.org/confluence/display/seccode/DCL03-C.+Use+a+static+assertion+to+test+the+value+of+a+constant+expression |
be9ba3531afb
cleaning up code. Changing HUGE_VAL to INFINITY.
Mario de Sousa <msousa@fe.up.pt>
parents:
604
diff
changeset
|
100 |
* struct {int a, b, c, d} header_t; |
be9ba3531afb
cleaning up code. Changing HUGE_VAL to INFINITY.
Mario de Sousa <msousa@fe.up.pt>
parents:
604
diff
changeset
|
101 |
* e.g.: static_assert(offsetof(struct header_t, c) == 8, "Compile time error message."); |
be9ba3531afb
cleaning up code. Changing HUGE_VAL to INFINITY.
Mario de Sousa <msousa@fe.up.pt>
parents:
604
diff
changeset
|
102 |
*/ |
be9ba3531afb
cleaning up code. Changing HUGE_VAL to INFINITY.
Mario de Sousa <msousa@fe.up.pt>
parents:
604
diff
changeset
|
103 |
|
be9ba3531afb
cleaning up code. Changing HUGE_VAL to INFINITY.
Mario de Sousa <msousa@fe.up.pt>
parents:
604
diff
changeset
|
104 |
#include <float.h> |
be9ba3531afb
cleaning up code. Changing HUGE_VAL to INFINITY.
Mario de Sousa <msousa@fe.up.pt>
parents:
604
diff
changeset
|
105 |
#if (LDBL_MANT_DIG == 53) /* NOTE: 64 bit IEC559 real has 53 bits for mantissa! */ |
890
499486ece119
Fix compilation error on platforms where real64_t is mapped onto 'long double'
mjsousa
parents:
760
diff
changeset
|
106 |
#define real64_tX long_double /* so we can later use #if (real64_t == long_double) directives in the code! */ |
499486ece119
Fix compilation error on platforms where real64_t is mapped onto 'long double'
mjsousa
parents:
760
diff
changeset
|
107 |
#define real64_t long double /* NOTE: no underscore '_' between 'long' and 'double' */ |
607
be9ba3531afb
cleaning up code. Changing HUGE_VAL to INFINITY.
Mario de Sousa <msousa@fe.up.pt>
parents:
604
diff
changeset
|
108 |
#define REAL64_MAX LDBL_MAX |
be9ba3531afb
cleaning up code. Changing HUGE_VAL to INFINITY.
Mario de Sousa <msousa@fe.up.pt>
parents:
604
diff
changeset
|
109 |
#elif ( DBL_MANT_DIG == 53) /* NOTE: 64 bit IEC559 real has 53 bits for mantissa! */ |
890
499486ece119
Fix compilation error on platforms where real64_t is mapped onto 'long double'
mjsousa
parents:
760
diff
changeset
|
110 |
#define real64_tX double |
499486ece119
Fix compilation error on platforms where real64_t is mapped onto 'long double'
mjsousa
parents:
760
diff
changeset
|
111 |
#define real64_t double |
607
be9ba3531afb
cleaning up code. Changing HUGE_VAL to INFINITY.
Mario de Sousa <msousa@fe.up.pt>
parents:
604
diff
changeset
|
112 |
#define REAL64_MAX DBL_MAX |
be9ba3531afb
cleaning up code. Changing HUGE_VAL to INFINITY.
Mario de Sousa <msousa@fe.up.pt>
parents:
604
diff
changeset
|
113 |
#elif ( FLT_MANT_DIG == 53) /* NOTE: 64 bit IEC559 real has 53 bits for mantissa! */ |
890
499486ece119
Fix compilation error on platforms where real64_t is mapped onto 'long double'
mjsousa
parents:
760
diff
changeset
|
114 |
#define real64_tX float |
499486ece119
Fix compilation error on platforms where real64_t is mapped onto 'long double'
mjsousa
parents:
760
diff
changeset
|
115 |
#define real64_t float |
607
be9ba3531afb
cleaning up code. Changing HUGE_VAL to INFINITY.
Mario de Sousa <msousa@fe.up.pt>
parents:
604
diff
changeset
|
116 |
#define REAL64_MAX FLT_MAX |
be9ba3531afb
cleaning up code. Changing HUGE_VAL to INFINITY.
Mario de Sousa <msousa@fe.up.pt>
parents:
604
diff
changeset
|
117 |
#else |
be9ba3531afb
cleaning up code. Changing HUGE_VAL to INFINITY.
Mario de Sousa <msousa@fe.up.pt>
parents:
604
diff
changeset
|
118 |
#error Could not find a 64 bit floating point data type on this platform. Aborting... |
be9ba3531afb
cleaning up code. Changing HUGE_VAL to INFINITY.
Mario de Sousa <msousa@fe.up.pt>
parents:
604
diff
changeset
|
119 |
#endif |
be9ba3531afb
cleaning up code. Changing HUGE_VAL to INFINITY.
Mario de Sousa <msousa@fe.up.pt>
parents:
604
diff
changeset
|
120 |
|
be9ba3531afb
cleaning up code. Changing HUGE_VAL to INFINITY.
Mario de Sousa <msousa@fe.up.pt>
parents:
604
diff
changeset
|
121 |
|
be9ba3531afb
cleaning up code. Changing HUGE_VAL to INFINITY.
Mario de Sousa <msousa@fe.up.pt>
parents:
604
diff
changeset
|
122 |
#if (LDBL_MANT_DIG == 24) /* NOTE: 32 bit IEC559 real has 24 bits for mantissa! */ |
890
499486ece119
Fix compilation error on platforms where real64_t is mapped onto 'long double'
mjsousa
parents:
760
diff
changeset
|
123 |
#define real32_tX long_double /* so we can later use #if (real32_t == long_double) directives in the code! */ |
499486ece119
Fix compilation error on platforms where real64_t is mapped onto 'long double'
mjsousa
parents:
760
diff
changeset
|
124 |
#define real32_t long double /* NOTE: no underscore '_' between 'long' and 'double' */ |
607
be9ba3531afb
cleaning up code. Changing HUGE_VAL to INFINITY.
Mario de Sousa <msousa@fe.up.pt>
parents:
604
diff
changeset
|
125 |
#define REAL32_MAX LDBL_MAX |
be9ba3531afb
cleaning up code. Changing HUGE_VAL to INFINITY.
Mario de Sousa <msousa@fe.up.pt>
parents:
604
diff
changeset
|
126 |
#elif ( DBL_MANT_DIG == 24) /* NOTE: 32 bit IEC559 real has 24 bits for mantissa! */ |
890
499486ece119
Fix compilation error on platforms where real64_t is mapped onto 'long double'
mjsousa
parents:
760
diff
changeset
|
127 |
#define real32_tX double |
499486ece119
Fix compilation error on platforms where real64_t is mapped onto 'long double'
mjsousa
parents:
760
diff
changeset
|
128 |
#define real32_t double |
607
be9ba3531afb
cleaning up code. Changing HUGE_VAL to INFINITY.
Mario de Sousa <msousa@fe.up.pt>
parents:
604
diff
changeset
|
129 |
#define REAL32_MAX DBL_MAX |
be9ba3531afb
cleaning up code. Changing HUGE_VAL to INFINITY.
Mario de Sousa <msousa@fe.up.pt>
parents:
604
diff
changeset
|
130 |
#elif ( FLT_MANT_DIG == 24) /* NOTE: 32 bit IEC559 real has 24 bits for mantissa! */ |
890
499486ece119
Fix compilation error on platforms where real64_t is mapped onto 'long double'
mjsousa
parents:
760
diff
changeset
|
131 |
#define real32_tX float |
499486ece119
Fix compilation error on platforms where real64_t is mapped onto 'long double'
mjsousa
parents:
760
diff
changeset
|
132 |
#define real32_t float |
607
be9ba3531afb
cleaning up code. Changing HUGE_VAL to INFINITY.
Mario de Sousa <msousa@fe.up.pt>
parents:
604
diff
changeset
|
133 |
#define REAL32_MAX FLT_MAX |
be9ba3531afb
cleaning up code. Changing HUGE_VAL to INFINITY.
Mario de Sousa <msousa@fe.up.pt>
parents:
604
diff
changeset
|
134 |
#else |
be9ba3531afb
cleaning up code. Changing HUGE_VAL to INFINITY.
Mario de Sousa <msousa@fe.up.pt>
parents:
604
diff
changeset
|
135 |
#error Could not find a 32 bit floating point data type on this platform. Aborting... |
be9ba3531afb
cleaning up code. Changing HUGE_VAL to INFINITY.
Mario de Sousa <msousa@fe.up.pt>
parents:
604
diff
changeset
|
136 |
#endif |
be9ba3531afb
cleaning up code. Changing HUGE_VAL to INFINITY.
Mario de Sousa <msousa@fe.up.pt>
parents:
604
diff
changeset
|
137 |
|
be9ba3531afb
cleaning up code. Changing HUGE_VAL to INFINITY.
Mario de Sousa <msousa@fe.up.pt>
parents:
604
diff
changeset
|
138 |
|
be9ba3531afb
cleaning up code. Changing HUGE_VAL to INFINITY.
Mario de Sousa <msousa@fe.up.pt>
parents:
604
diff
changeset
|
139 |
|
be9ba3531afb
cleaning up code. Changing HUGE_VAL to INFINITY.
Mario de Sousa <msousa@fe.up.pt>
parents:
604
diff
changeset
|
140 |
#include <math.h> |
be9ba3531afb
cleaning up code. Changing HUGE_VAL to INFINITY.
Mario de Sousa <msousa@fe.up.pt>
parents:
604
diff
changeset
|
141 |
#ifndef INFINITY |
be9ba3531afb
cleaning up code. Changing HUGE_VAL to INFINITY.
Mario de Sousa <msousa@fe.up.pt>
parents:
604
diff
changeset
|
142 |
#error Could not find the macro that defines the value for INFINITY in the current platform. |
be9ba3531afb
cleaning up code. Changing HUGE_VAL to INFINITY.
Mario de Sousa <msousa@fe.up.pt>
parents:
604
diff
changeset
|
143 |
#endif |
be9ba3531afb
cleaning up code. Changing HUGE_VAL to INFINITY.
Mario de Sousa <msousa@fe.up.pt>
parents:
604
diff
changeset
|
144 |
#ifndef NAN |
be9ba3531afb
cleaning up code. Changing HUGE_VAL to INFINITY.
Mario de Sousa <msousa@fe.up.pt>
parents:
604
diff
changeset
|
145 |
#error Could not find the macro that defines the value for NAN in the current platform. |
be9ba3531afb
cleaning up code. Changing HUGE_VAL to INFINITY.
Mario de Sousa <msousa@fe.up.pt>
parents:
604
diff
changeset
|
146 |
#endif |
be9ba3531afb
cleaning up code. Changing HUGE_VAL to INFINITY.
Mario de Sousa <msousa@fe.up.pt>
parents:
604
diff
changeset
|
147 |
|
be9ba3531afb
cleaning up code. Changing HUGE_VAL to INFINITY.
Mario de Sousa <msousa@fe.up.pt>
parents:
604
diff
changeset
|
148 |
|
be9ba3531afb
cleaning up code. Changing HUGE_VAL to INFINITY.
Mario de Sousa <msousa@fe.up.pt>
parents:
604
diff
changeset
|
149 |
|
645
e01ede1c9862
Allow the use of PRId64, PRIu64 and PRIx64 printf formating macros globally.
Mario de Sousa <msousa@fe.up.pt>
parents:
607
diff
changeset
|
150 |
/* get the printf format macros for printing variables of fixed data size |
e01ede1c9862
Allow the use of PRId64, PRIu64 and PRIx64 printf formating macros globally.
Mario de Sousa <msousa@fe.up.pt>
parents:
607
diff
changeset
|
151 |
* e.g. int64_t v; printf("value=%"PRId64" !!\n", v); |
e01ede1c9862
Allow the use of PRId64, PRIu64 and PRIx64 printf formating macros globally.
Mario de Sousa <msousa@fe.up.pt>
parents:
607
diff
changeset
|
152 |
* e.g. uint64_t v; printf("value=%"PRIu64" !!\n", v); |
e01ede1c9862
Allow the use of PRId64, PRIu64 and PRIx64 printf formating macros globally.
Mario de Sousa <msousa@fe.up.pt>
parents:
607
diff
changeset
|
153 |
* e.g. uint64_t v; printf("value=%"PRIx64" !!\n", v); // hexadecimal format |
e01ede1c9862
Allow the use of PRId64, PRIu64 and PRIx64 printf formating macros globally.
Mario de Sousa <msousa@fe.up.pt>
parents:
607
diff
changeset
|
154 |
*/ |
760 | 155 |
#ifndef __STDC_FORMAT_MACROS |
645
e01ede1c9862
Allow the use of PRId64, PRIu64 and PRIx64 printf formating macros globally.
Mario de Sousa <msousa@fe.up.pt>
parents:
607
diff
changeset
|
156 |
#define __STDC_FORMAT_MACROS |
760 | 157 |
#endif |
645
e01ede1c9862
Allow the use of PRId64, PRIu64 and PRIx64 printf formating macros globally.
Mario de Sousa <msousa@fe.up.pt>
parents:
607
diff
changeset
|
158 |
#include <inttypes.h> |
607
be9ba3531afb
cleaning up code. Changing HUGE_VAL to INFINITY.
Mario de Sousa <msousa@fe.up.pt>
parents:
604
diff
changeset
|
159 |
|
be9ba3531afb
cleaning up code. Changing HUGE_VAL to INFINITY.
Mario de Sousa <msousa@fe.up.pt>
parents:
604
diff
changeset
|
160 |
|
654
7421cb63defa
list_c: initial capacity. ERROR_MSG(msg,...) supports optional arguments now.
agraeper
parents:
645
diff
changeset
|
161 |
#endif // #ifndef _MAIN_HH |