changeset 12083:8becf4c44755 draft

(svn r16492) -Remove: support for gcc2. It hasn't been able to compile OTTD for months. All attempts to do another workaround failed.
author smatz <smatz@openttd.org>
date Mon, 01 Jun 2009 11:49:46 +0000
parents d092f17a921d
children e1051929e7b8
files Makefile.src.in config.lib src/blitter/32bpp_optimized.hpp src/blitter/8bpp_optimized.hpp src/debug.h src/gamelog.cpp src/newgrf_text.cpp src/script/squirrel_class.hpp src/script/squirrel_helper_type.hpp src/signal.cpp src/spritecache.cpp src/spritecache.h src/stdafx.h src/strings.cpp src/table/sprites.h
diffstat 15 files changed, 26 insertions(+), 82 deletions(-) [+]
line wrap: on
line diff
--- a/Makefile.src.in
+++ b/Makefile.src.in
@@ -29,7 +29,6 @@
 SORT         = !!SORT!!
 REVISION     = !!REVISION!!
 AWK          = !!AWK!!
-GCC295       = !!GCC295!!
 CONFIG_CACHE_COMPILER = $(SRC_OBJS_DIR)/!!CONFIG_CACHE_COMPILER!!
 CONFIG_CACHE_LINKER   = $(SRC_OBJS_DIR)/!!CONFIG_CACHE_LINKER!!
 CONFIG_CACHE_ENDIAN   = $(SRC_OBJS_DIR)/!!CONFIG_CACHE_ENDIAN!!
@@ -54,20 +53,6 @@
 
 ENDIAN_TARGETS := endian_target.h $(ENDIAN_CHECK)
 
-# This 'sed' basicly just removes 'const' from the line if it is a 2+D array
-# For more information, please check:
-#  http://maillist.openttd.org/pipermail/devs/2007-April/000284.html
-#  http://maillist.openttd.org/pipermail/devs/2007-February/000248.html
-GCC295_FIX=sed -r 's@^(\t*)(.*)( const )([A-Za-z0-9_ ]+(\[.*\]){2,})(( = \{)|(;))(.*)$$@\1\2 \4\6\8\9@g'
-# This 'sed' removes the 3rd '4' in the # lines of the -E output of
-#  gcc 2.95.3 and lower, as it should indicate that it is a C-linkage, but the
-#  compiler can't handle that information (just don't ask). So we remove it
-#  and then it compiles happily and without bitching :)
-# Furthermore gcc 2.95 has some trouble with protected and private when
-#  accessing the protected/private stuff of the enclosing class (or the
-#  super class of the enclosing class).
-GCC295_FIX_2=sed -e 's@\(^\# [0-9][0-9]* "[^"]*"[ 0-9]*\) 4$$@\1@g;s@private:@public:@g;s@protected:@public:@g'
-
 # Check if we want to show what we are doing
 ifdef VERBOSE
 	Q =
@@ -240,11 +225,7 @@
 
 $(OBJS_CPP): %.o: $(SRC_DIR)/%.cpp $(DEP_MASK) $(FILE_DEP)
 	$(E) '$(STAGE) Compiling $(<:$(SRC_DIR)/%.cpp=%.cpp)'
-ifeq ($(GCC295), 1)
-	$(Q)$(CXX_HOST) -E $(CFLAGS) $< | $(GCC295_FIX) | $(GCC295_FIX_2) | $(CXX_HOST) $(CFLAGS) -c -o $@ -x c++ -
-else
 	$(Q)$(CXX_HOST) $(CFLAGS) -c -o $@ $<
-endif
 
 $(OBJS_MM): %.o: $(SRC_DIR)/%.mm $(DEP_MASK) $(FILE_DEP)
 	$(E) '$(STAGE) Compiling $(<:$(SRC_DIR)/%.mm=%.mm)'
--- a/config.lib
+++ b/config.lib
@@ -1100,34 +1100,23 @@
 		# Enable some things only for certain GCC versions
 		cc_version=`$cc_host -dumpversion | cut -c 1,3`
 
-		if [ $cc_version -ge 29 ]; then
-			CFLAGS="$CFLAGS -Wall -Wno-multichar -Wsign-compare -Wundef"
-			CFLAGS="$CFLAGS -Wwrite-strings -Wpointer-arith"
-			CFLAGS="$CFLAGS -Wno-uninitialized"
-
-			CC_CFLAGS="$CC_CFLAGS -Wstrict-prototypes"
+		if [ $cc_version -lt 30 ]; then
+			log 1 "configure: error: gcc older than 3.0 can't compile OpenTTD because of its poor template support"
+			exit 1
 		fi
 
-		gcc295=""
-		if [ "$cc_version" = 29 ]; then
-			# Make sure we mark GCC 2.95 flag for Makefile.src.in, as we
-			#  need a lovely hack there to make it compile correctly.
-			gcc295="1"
-
-			# Disable warnings about unused variables when
-			# compiling with asserts disabled
-			if [ $enable_assert -eq 0 ]; then
-				CFLAGS="$CFLAGS -Wno-unused"
-			fi
-		fi
-
-		if [ $cc_version -ge 30 ]; then
-			CFLAGS="$CFLAGS -W -Wno-unused-parameter -Wformat=2"
-			CFLAGS="$CFLAGS -Wredundant-decls"
+		CFLAGS="$CFLAGS -Wall -Wno-multichar -Wsign-compare -Wundef"
+		CFLAGS="$CFLAGS -Wwrite-strings -Wpointer-arith"
+		CFLAGS="$CFLAGS -Wno-uninitialized"
+
+		CFLAGS="$CFLAGS -W -Wno-unused-parameter -Wformat=2"
+		CFLAGS="$CFLAGS -Wredundant-decls"
+
+		CC_CFLAGS="$CC_CFLAGS -Wstrict-prototypes"
+
+		if [ $enable_assert -eq 0 ]; then
 			# Do not warn about unused variables when building without asserts
-			if [ $enable_assert -eq 0 ]; then
-				CFLAGS="$CFLAGS -Wno-unused-variable"
-			fi
+			CFLAGS="$CFLAGS -Wno-unused-variable"
 		fi
 
 		if [ $cc_version -ge 34 ]; then
@@ -2666,7 +2655,6 @@
 		s@!!CONFIGURE_FILES!!@$CONFIGURE_FILES@g;
 		s@!!REVISION!!@$revision@g;
 		s@!!AWK!!@$awk@g;
-		s@!!GCC295!!@$gcc295@g;
 		s@!!DISTCC!!@$distcc@g;
 	"
 
--- a/src/blitter/32bpp_optimized.hpp
+++ b/src/blitter/32bpp_optimized.hpp
@@ -12,7 +12,7 @@
 public:
 	struct SpriteData {
 		uint32 offset[ZOOM_LVL_COUNT][2];
-		byte data[VARARRAY_SIZE];
+		byte data[];
 	};
 
 	/* virtual */ void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom);
--- a/src/blitter/8bpp_optimized.hpp
+++ b/src/blitter/8bpp_optimized.hpp
@@ -12,7 +12,7 @@
 public:
 	struct SpriteData {
 		uint32 offset[ZOOM_LVL_COUNT]; ///< offsets (from .data) to streams for different zoom levels
-		byte data[VARARRAY_SIZE];      ///< data, all zoomlevels
+		byte data[];                   ///< data, all zoomlevels
 	};
 
 	/* virtual */ void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom);
--- a/src/debug.h
+++ b/src/debug.h
@@ -20,17 +20,9 @@
  */
 
 #ifdef NO_DEBUG_MESSAGES
-	#if defined(__GNUC__) && (__GNUC__ < 3)
-		#define DEBUG(name, level, args...) { }
-	#else
-		#define DEBUG(name, level, ...) { }
-	#endif
+	#define DEBUG(name, level, ...) { }
 #else /* NO_DEBUG_MESSAGES */
-	#if defined(__GNUC__) && (__GNUC__ < 3)
-		#define DEBUG(name, level, args...) if ((level == 0) || ( _debug_ ## name ## _level >= level)) debug(#name, args)
-	#else
-		#define DEBUG(name, level, ...) if (level == 0 || _debug_ ## name ## _level >= level) debug(#name, __VA_ARGS__)
-	#endif
+	#define DEBUG(name, level, ...) if (level == 0 || _debug_ ## name ## _level >= level) debug(#name, __VA_ARGS__)
 
 	extern int _debug_ai_level;
 	extern int _debug_driver_level;
--- a/src/gamelog.cpp
+++ b/src/gamelog.cpp
@@ -591,7 +591,7 @@
 /** List of GRFs using array of pointers instead of linked list */
 struct GRFList {
 	uint n;
-	const GRFConfig *grf[VARARRAY_SIZE];
+	const GRFConfig *grf[];
 };
 
 /** Generates GRFList
--- a/src/newgrf_text.cpp
+++ b/src/newgrf_text.cpp
@@ -80,7 +80,7 @@
 	public:
 		GRFText *next;
 		byte langid;
-		char text[VARARRAY_SIZE];
+		char text[];
 };
 
 
--- a/src/script/squirrel_class.hpp
+++ b/src/script/squirrel_class.hpp
@@ -5,14 +5,6 @@
 #ifndef SQUIRREL_CLASS_HPP
 #define SQUIRREL_CLASS_HPP
 
-#if (__GNUC__ == 2)
-/* GCC 2.95 doesn't like to have SQConvert::DefSQStaticCallback inside a
- *  template (it gives an internal error 373). Above that, it doesn't listen
- *  to 'using namespace' inside a function of a template. So for GCC 2.95 we
- *  do it in the global space to avoid compiler errors. */
-using namespace SQConvert;
-#endif /* __GNUC__ == 2 */
-
 /**
  * The template to define classes in Squirrel. It takes care of the creation
  *  and calling of such classes, to make the AI Layer cleaner while having a
--- a/src/script/squirrel_helper_type.hpp
+++ b/src/script/squirrel_helper_type.hpp
@@ -7,7 +7,7 @@
 
 struct Array {
 	int32 size;
-	int32 array[VARARRAY_SIZE];
+	int32 array[];
 };
 
 #endif /* SQUIRREL_HELPER_TYPE_HPP */
--- a/src/signal.cpp
+++ b/src/signal.cpp
@@ -19,8 +19,7 @@
 	SIG_GLOB_UPDATE =  64, ///< how many items need to be in _globset to force update
 };
 
-/* need to typecast to compile with MorphOS */
-assert_compile((int)SIG_GLOB_UPDATE <= (int)SIG_GLOB_SIZE);
+assert_compile(SIG_GLOB_UPDATE <= SIG_GLOB_SIZE);
 
 /** incidating trackbits with given enterdir */
 static const TrackBitsByte _enterdir_to_trackbits[DIAGDIR_END] = {
--- a/src/spritecache.cpp
+++ b/src/spritecache.cpp
@@ -67,7 +67,7 @@
 
 struct MemBlock {
 	size_t size;
-	byte data[VARARRAY_SIZE];
+	byte data[];
 };
 
 static uint _sprite_lru_counter;
--- a/src/spritecache.h
+++ b/src/spritecache.h
@@ -12,7 +12,7 @@
 	uint16 width;
 	int16 x_offs;
 	int16 y_offs;
-	byte data[VARARRAY_SIZE];
+	byte data[];
 };
 
 extern uint _sprite_cache_size;
--- a/src/stdafx.h
+++ b/src/stdafx.h
@@ -116,9 +116,6 @@
 	#define printf pspDebugScreenPrintf
 #endif /* PSP */
 
-/* by default we use [] var arrays */
-#define VARARRAY_SIZE
-
 /* Stuff for GCC */
 #if defined(__GNUC__)
 	#define NORETURN __attribute__ ((noreturn))
@@ -129,11 +126,6 @@
 	/* Warn about functions using 'printf' format syntax. First argument determines which parameter
 	 * is the format string, second argument is start of values passed to printf. */
 	#define WARN_FORMAT(string, args) __attribute__ ((format (printf, string, args)))
-
-	#if (__GNUC__ == 2)
-		#undef VARARRAY_SIZE
-		#define VARARRAY_SIZE 0
-	#endif
 #endif /* __GNUC__ */
 
 #if defined(__WATCOMC__)
--- a/src/strings.cpp
+++ b/src/strings.cpp
@@ -45,7 +45,7 @@
 static char *FormatString(char *buff, const char *str, int64 *argv, uint casei, const char *last);
 
 struct LanguagePack : public LanguagePackHeader {
-	char data[VARARRAY_SIZE]; // list of strings
+	char data[]; // list of strings
 };
 
 static char **_langpack_offs;
--- a/src/table/sprites.h
+++ b/src/table/sprites.h
@@ -1450,7 +1450,7 @@
 
 assert_compile( (1 << TRANSPARENT_BIT & SPRITE_MASK) == 0 );
 assert_compile( (1 << RECOLOUR_BIT & SPRITE_MASK) == 0 );
-assert_compile( !(TRANSPARENT_BIT == RECOLOUR_BIT) );
+assert_compile( TRANSPARENT_BIT != RECOLOUR_BIT );
 assert_compile( (1 << TRANSPARENT_BIT & PALETTE_MASK) == 0);
 assert_compile( (1 << RECOLOUR_BIT & PALETTE_MASK) == 0 );