Game Development Community

Could somebody remind me why we use S32/F32 syntax instead of simple int/float again?

by Chris Calef · in Torque 3D Professional · 09/27/2014 (12:03 pm) · 5 replies

This could be a stupid question but I've never been quite clear on the actual advantage of Torque's S32/F32 etc syntax instead of using the basic C data types as is... It certainly makes it a pain in the neck porting code in and out of Torque. I've often considered sterilizing them all out of my code and going back to the basic types. Is there still a compelling reason for doing it the "Torque way"?

#1
09/27/2014 (12:15 pm)
Not completely sure.. I think it originated as a "fix inconsistencies between compilers/platforms" thing, but i don't know how relevant that is anymore.

Personally I prefer the Torque way syntactically, but I do see your point.
#2
09/27/2014 (12:24 pm)
I believe Lukas is right - once upon a time you couldn't be sure what size you'd actually get using "naked" types.

Probably not generally relevant any more....
#3
09/27/2014 (12:31 pm)
Huh, okay, thanks.
#4
09/27/2014 (1:47 pm)
It's much easier to type U32 than "unsigned int" every time you need to use an unsigned 32bit integer type. It also tells you a lot more about the storage requirements of the type at a casual glance than just "unsigned int".

And of course as mentioned there is the "consistency between compilers / platforms" angle. Though that is less relevant today.

Also if you have a look around, you may notice a lot of projects use similar typedefs. e.g. "u32", "uint32_t", so it's actually quite common to do this. In the end though its up to you if you want to follow through with it.
#5
09/27/2014 (5:41 pm)
As James has said, it makes it simple to know what exactly the intended size of the variable should be. Also as James has pointed out that a lot of other projects use similar data types. From my experience the lowercase variant of what Torque uses has been used for a long time in embedded software development suites for Blackfin, ARM, TI MSP430, and AVR.