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 |
54 |
54 |
55 /* Determine, for the current platform, which data type (float, double or long double) uses 64 bits. */ |
55 /* Determine, for the current platform, which data type (float, double or long double) uses 64 bits. */ |
56 /* NOTE: we cant use sizeof() in pre-processor directives, so we do it another way... */ |
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 |
57 #include <float.h> |
65 #include <float.h> |
58 #if (LDBL_MANT_DIG == 53) /* NOTE: 64 bit IEC559 real has 53 bits for mantissa! */ |
66 #if (LDBL_MANT_DIG == 53) /* NOTE: 64 bit IEC559 real has 53 bits for mantissa! */ |
59 #define long_double long double |
67 #define long_double long double |
60 #define real64_t long_double /* so we can later use #if (real64_t == long_double) directives in the code! */ |
68 #define real64_t long_double /* so we can later use #if (real64_t == long_double) directives in the code! */ |
61 #elif ( DBL_MANT_DIG == 53) /* NOTE: 64 bit IEC559 real has 53 bits for mantissa! */ |
69 #elif ( DBL_MANT_DIG == 53) /* NOTE: 64 bit IEC559 real has 53 bits for mantissa! */ |