Game Development Community

Cannot build in xCode 2.1 - Enumeration problem.

by Will Burgers · in Torque Game Engine · 11/29/2005 (9:37 pm) · 2 replies

My current torque project no longer builds now that I have upgraded to OS 10.4.x, and xCode 2.1.
I get the following errors:

error: a cast to a type other than an integral or enumeration type cannot appear in a constant-expression
error: '->' cannot appear in a constant-expression
error: '&' cannot appear in a constant-expression

for each of the three lines in the following enumeration:

/// Header sizes for events defined later on.
enum HeaderSizes
{
/// Byte offset to payload of a PacketReceiveEvent
PacketReceiveEventHeaderSize = Offset(data,PacketReceiveEvent),

/// Byte offset to payload of a ConnectedReceiveEvent
ConnectedReceiveEventHeaderSize = Offset(data,ConnectedReceiveEvent),

/// Byte offset to payload of a ConsoleEvent
ConsoleEventHeaderSize = Offset(data,ConsoleEvent)

};

in the file event.h.

I haven't made changes in this file and do not know how to go about correcting these errors.
Any help would be greatly appreciated!

Thanks,
Will

#1
11/29/2005 (9:53 pm)
This is a GCC4 compatibility issue that was fixed in TGE 1.4, which has now been released (yay!) .

Basically, using the Offset() macro magic in an enum is against the C/C++ standards.
In 1.4, we changed it from an enum to three seperate const U32's, like this:
/// Header sizes for events defined later on.
/// Byte offset to payload of a PacketReceiveEvent
const U32 PacketReceiveEventHeaderSize = Offset(data,PacketReceiveEvent);
/// Byte offset to payload of a ConnectedReceiveEvent
const U32 ConnectedReceiveEventHeaderSize = Offset(data,ConnectedReceiveEvent);
/// Byte offset to payload of a ConsoleEvent
const U32 ConsoleEventHeaderSize = Offset(data,ConsoleEvent);

There are myriad GCC4 fixes & tweaks in 1.4. I seriously suggest upgrading to 1.4.
Unless you're 95% done with your project, upgrading is most probably possible.

If upgrading is not possible, the quick fix is to tell Xcode to use GCC3.3, instead of GCC4.

Cheers!

/Paul
#2
11/29/2005 (10:22 pm)
Ah, thank you very much!

Yeah, my project right now has been heavily modified from it's 1.3 base, but I will probably try to upgrade to 1.4, as I have already fallen in love with it.

Thanks for the quick response!
Will