48 |
48 |
49 #include <stdio.h> // required for NULL |
49 #include <stdio.h> // required for NULL |
50 #include <vector> |
50 #include <vector> |
51 #include <string> |
51 #include <string> |
52 #include <stdint.h> // required for uint64_t, etc... |
52 #include <stdint.h> // required for uint64_t, etc... |
53 |
53 #include "../main.hh" // required for uint8_t, real_64_t, ..., and the macros INT8_MAX, REAL32_MAX, ... */ |
54 |
54 |
55 /* Determine, for the current platform, which data type (float, double or long double) uses 64 bits. */ |
55 |
56 /* NOTE: We cant use sizeof() in pre-processor directives, so we have to do it another way... */ |
|
57 /* CURIOSITY: We can use sizeof() and offsetof() inside static_assert() but: |
|
58 * - this only allows us to make assertions, and not #define new macros |
|
59 * - 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. |
|
60 * https://www.securecoding.cert.org/confluence/display/seccode/DCL03-C.+Use+a+static+assertion+to+test+the+value+of+a+constant+expression |
|
61 * struct {int a, b, c, d} header_t; |
|
62 * e.g.: static_assert(offsetof(struct header_t, c) == 8, "Compile time error message."); |
|
63 */ |
|
64 |
|
65 #include <float.h> |
|
66 #if (LDBL_MANT_DIG == 53) /* NOTE: 64 bit IEC559 real has 53 bits for mantissa! */ |
|
67 #define long_double long double |
|
68 #define real64_t long_double /* so we can later use #if (real64_t == long_double) directives in the code! */ |
|
69 #elif ( DBL_MANT_DIG == 53) /* NOTE: 64 bit IEC559 real has 53 bits for mantissa! */ |
|
70 #define real64_t double |
|
71 #elif ( FLT_MANT_DIG == 53) /* NOTE: 64 bit IEC559 real has 53 bits for mantissa! */ |
|
72 #define real64_t float |
|
73 #else |
|
74 #error Could not find a 64 bit floating point data type on this platform. Aborting... |
|
75 #endif |
|
76 |
56 |
77 |
57 |
78 /* Forward declaration of the visitor interface |
58 /* Forward declaration of the visitor interface |
79 * declared in the visitor.hh file |
59 * declared in the visitor.hh file |
80 * We cannot include the visitor.hh file, as it will |
60 * We cannot include the visitor.hh file, as it will |