Error: anachronistic old-style base class initializer

By , last updated February 27, 2014

I got this error when trying to build our game Burnt Islands for Linux. It was bepuzzling. There was nothing wrong with the syntax, it compiled under Windows with no problems. I know G++ have its quirks, however, this was strange.

This was the original code it didn’t like.

class KeyMessage : public Message<MESSAGE_KEY>
		explicit KeyMessage( bool pressed, Key key, bool shift, bool ctrl, bool continuous )
			: Message()
			, pressed( pressed )
			, key( key )
			, shift( shift )
			, CTRL( ctrl )
			, continuous( continuous )

		virtual ~KeyMessage() {}


		bool		pressed;
		Key 		key;
		bool		shift;
		bool		CTRL;
		bool		continuous;

The error given was this

KeysMessages.hpp: In constructor ‘KeyMessage::KeyMessage(bool, framework::messages::Key, bool, bool, bool)’:
KeysMessages.hpp:107:8: error: anachronistic old-style base class initializer [-fpermissive]
KeysMessages.hpp:102:14: error: multiple initializations given for base ‘Message’

It turned out there is a macro with the name CTRL hidden somewhere in the includes in Linux.

The fix was very simple. I had only to rename CTRL to Ctrl, and then it compiled willingly under both Windows and Linux.

Next time this error comes around, it is probably a macro doing strange things with your code.


Be the first to comment.

Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>