Fixing includes to define INTxx_MAX etc...
authorMario de Sousa <msousa@fe.up.pt>
Wed, 18 Jul 2012 16:56:36 +0100
changeset 604 2989051a0a64
parent 603 a45a62dd6df9
child 605 06caf4782e51
Fixing includes to define INTxx_MAX etc...
main.hh
stage3/constant_folding.cc
stage3/fill_candidate_datatypes.cc
--- a/main.hh	Sat Jul 14 11:09:26 2012 +0200
+++ b/main.hh	Wed Jul 18 16:56:36 2012 +0100
@@ -34,8 +34,38 @@
 #ifndef _MAIN_HH
 #define _MAIN_HH
 
+
+ /* Get the definition of INT16_MAX, INT16_MIN, UINT64_MAX, INT64_MAX, INT64_MIN, ... */
+
+#define __STDC_LIMIT_MACROS /* required when including from C++ source code. */
+#include <stdint.h>         
+
+#ifndef   UINT64_MAX 
+  #define UINT64_MAX (std::numeric_limits< uint64_t >::max())
+#endif
+#ifndef    INT64_MAX 
+  #define  INT64_MAX (std::numeric_limits<  int64_t >::max())
+#endif
+#ifndef    INT64_MIN
+  #define  INT64_MIN (std::numeric_limits<  int64_t >::min()) 
+#endif
+
+#if    (real64_t  == float)
+  #define HUGE_VAL64  HUGE_VALF
+#elif  (real64_t  == double)
+  #define HUGE_VAL64  HUGE_VAL
+#elif  (real64_t  == long_double)
+  #define HUGE_VAL64  HUGE_VALL
+#else 
+  #error Could not determine which data type is being used for real64_t (defined in absyntax.hh). Aborting!
+#endif
+
+
+
+
  /* Function used throughout the code --> used to report failed assertions (i.e. internal compiler errors)! */
-
+#include <stddef.h>  /* required for NULL */
+ 
 #define ERROR               error_exit(__FILE__,__LINE__)
 #define ERROR_MSG(msg, ...) error_exit(__FILE__,__LINE__, msg)
 // #define ERROR_MSG(msg, ...) error_exit(__FILE__,__LINE__, msg, __VA_ARGS__)
--- a/stage3/constant_folding.cc	Sat Jul 14 11:09:26 2012 +0200
+++ b/stage3/constant_folding.cc	Wed Jul 18 16:56:36 2012 +0100
@@ -126,35 +126,7 @@
 // #include <stdlib.h>  /* required for atoi() */
 #include <errno.h>   /* required for errno */
 
-
-
-#define __STDC_LIMIT_MACROS /* required for UINT64_MAX, INT64_MAX, INT64_MIN, ... */
-#include <stdint.h>         /* required for UINT64_MAX, INT64_MAX, INT64_MIN, ... */
-
-
-
-#ifndef   UINT64_MAX 
-  #define UINT64_MAX (std::numeric_limits< uint64_t >::max())
-#endif
-#ifndef    INT64_MAX 
-  #define  INT64_MAX (std::numeric_limits<  int64_t >::max())
-#endif
-#ifndef    INT64_MIN
-  #define  INT64_MIN (std::numeric_limits<  int64_t >::min()) 
-#endif
-
-#if    (real64_t  == float)
-  #define HUGE_VAL64  HUGE_VALF
-#elif  (real64_t  == double)
-  #define HUGE_VAL64  HUGE_VAL
-#elif  (real64_t  == long_double)
-  #define HUGE_VAL64  HUGE_VALL
-#else 
-  #error Could not determine which data type is being used for real64_t (defined in absyntax.hh). Aborting!
-#endif
-
-
-
+#include <../main.hh>         /* required for UINT64_MAX, INT64_MAX, INT64_MIN, ... */
 
 
 
--- a/stage3/fill_candidate_datatypes.cc	Sat Jul 14 11:09:26 2012 +0200
+++ b/stage3/fill_candidate_datatypes.cc	Wed Jul 18 16:56:36 2012 +0100
@@ -55,6 +55,7 @@
  *    BOOL, BYTE, WORD, DWORD, LWORD, USINT, SINT, UINT, INT, UDINT, DINT, ULINT, LINT (as well as the SAFE versions of these data tyes too!)
  */
 
+#include <../main.hh>         /* required for UINT64_MAX, INT64_MAX, INT64_MIN, ... */
 #include "fill_candidate_datatypes.hh"
 #include "datatype_functions.hh"
 #include <typeinfo>
@@ -141,24 +142,24 @@
       }
     }
     if (IS_OVERFLOW( uint64, symbol)) {
-  	      remove_from_candidate_datatype_list(&search_constant_type_c::bool_type_name,       symbol->candidate_datatypes);
-  	      remove_from_candidate_datatype_list(&search_constant_type_c::safebool_type_name,   symbol->candidate_datatypes);
-    	  remove_from_candidate_datatype_list(&search_constant_type_c::usint_type_name,      symbol->candidate_datatypes);
-    	  remove_from_candidate_datatype_list(&search_constant_type_c::safeusint_type_name,  symbol->candidate_datatypes);
-	      remove_from_candidate_datatype_list(&search_constant_type_c::byte_type_name,       symbol->candidate_datatypes);
-	      remove_from_candidate_datatype_list(&search_constant_type_c::safebyte_type_name,   symbol->candidate_datatypes);
-    	  remove_from_candidate_datatype_list(&search_constant_type_c::uint_type_name,       symbol->candidate_datatypes);
-    	  remove_from_candidate_datatype_list(&search_constant_type_c::safeuint_type_name,   symbol->candidate_datatypes);
-          remove_from_candidate_datatype_list(&search_constant_type_c::word_type_name,       symbol->candidate_datatypes);
-          remove_from_candidate_datatype_list(&search_constant_type_c::safeword_type_name,   symbol->candidate_datatypes);
-    	  remove_from_candidate_datatype_list(&search_constant_type_c::udint_type_name,      symbol->candidate_datatypes);
-    	  remove_from_candidate_datatype_list(&search_constant_type_c::safeudint_type_name,  symbol->candidate_datatypes);
-          remove_from_candidate_datatype_list(&search_constant_type_c::dword_type_name,      symbol->candidate_datatypes);
-          remove_from_candidate_datatype_list(&search_constant_type_c::safedword_type_name,  symbol->candidate_datatypes);
-    	  remove_from_candidate_datatype_list(&search_constant_type_c::ulint_type_name,      symbol->candidate_datatypes);
-    	  remove_from_candidate_datatype_list(&search_constant_type_c::safeulint_type_name,  symbol->candidate_datatypes);
-          remove_from_candidate_datatype_list(&search_constant_type_c::lword_type_name,      symbol->candidate_datatypes);
-          remove_from_candidate_datatype_list(&search_constant_type_c::safelword_type_name,  symbol->candidate_datatypes);
+	remove_from_candidate_datatype_list(&search_constant_type_c::bool_type_name,       symbol->candidate_datatypes);
+	remove_from_candidate_datatype_list(&search_constant_type_c::safebool_type_name,   symbol->candidate_datatypes);
+	remove_from_candidate_datatype_list(&search_constant_type_c::usint_type_name,      symbol->candidate_datatypes);
+	remove_from_candidate_datatype_list(&search_constant_type_c::safeusint_type_name,  symbol->candidate_datatypes);
+	remove_from_candidate_datatype_list(&search_constant_type_c::byte_type_name,       symbol->candidate_datatypes);
+	remove_from_candidate_datatype_list(&search_constant_type_c::safebyte_type_name,   symbol->candidate_datatypes);
+	remove_from_candidate_datatype_list(&search_constant_type_c::uint_type_name,       symbol->candidate_datatypes);
+	remove_from_candidate_datatype_list(&search_constant_type_c::safeuint_type_name,   symbol->candidate_datatypes);
+	remove_from_candidate_datatype_list(&search_constant_type_c::word_type_name,       symbol->candidate_datatypes);
+	remove_from_candidate_datatype_list(&search_constant_type_c::safeword_type_name,   symbol->candidate_datatypes);
+	remove_from_candidate_datatype_list(&search_constant_type_c::udint_type_name,      symbol->candidate_datatypes);
+	remove_from_candidate_datatype_list(&search_constant_type_c::safeudint_type_name,  symbol->candidate_datatypes);
+	remove_from_candidate_datatype_list(&search_constant_type_c::dword_type_name,      symbol->candidate_datatypes);
+	remove_from_candidate_datatype_list(&search_constant_type_c::safedword_type_name,  symbol->candidate_datatypes);
+	remove_from_candidate_datatype_list(&search_constant_type_c::ulint_type_name,      symbol->candidate_datatypes);
+	remove_from_candidate_datatype_list(&search_constant_type_c::safeulint_type_name,  symbol->candidate_datatypes);
+	remove_from_candidate_datatype_list(&search_constant_type_c::lword_type_name,      symbol->candidate_datatypes);
+	remove_from_candidate_datatype_list(&search_constant_type_c::safelword_type_name,  symbol->candidate_datatypes);
     }
   }
   /* Remove signed data types */