Source

Everything related to the code /
Tout ce qui touche au code
Post Reply
User avatar
Cire
Moderator
Posts: 350
Joined: Tue Oct 31, 2006 5:59 pm
Location: Somewhere on Earth

Source

Post by Cire » Sat Nov 04, 2006 4:48 pm

I've started to seriously look at the source code, and I have some questions regarding your compiler zuf.

#1. Does your compiler make use of #pragma compiler directives? Specifically 'once'. This sure beats encolsing #ifndef blah, #define blah #endif. I believe most compilers do, and one should get in the habbit of using this rather then the old style.

#2. I was curious if your up to bringing this more into standards by making use of namespaces?

#3 since we are building for different platforms I was wondering if we could make use a pch file, perhaps stdafx.h as is standards, it sure cuts down on compile time rebuilds, as well could we define a standard that would need changed for each platform so that at compile time it could do different operands then current. I suggest we define somethting like TA3D_PLATFORM_ARCH_LINUX or TA3D_PLATFORM_ARCH_WINDOWS, or TA3D_PLATFORM_ARCH_MAC, or TA3D_PLATFORM_ARCH_OTHER. I realize that we can already use different defines by platform specific includes already but this is something that we can use and don't need to worry about something somewhere messing with it. We could place this in our stdafx.h file within TA3D namespace.

#4 can we setup in our pch file a set of 'typedefs' that we can define as byte specific size in both unsigned and signed. I realize that it will require a number of changes throughout the code but that can be done over time, and would make things ALOT easier when we really start shuffeling data around through sockets and what not.
Something like this, though we might wana add floating, double to it as well.

Code: Select all

#ifdef TA3D_PLATFORM_ARCH_WINDOWS
	// 64-bit ints, guaranteed to be 8 bytes in size
	typedef unsigned __int64  uint64;
	typedef signed __int64      sint64;

	// 32-bit ints, guaranteed to be 4 bytes in size
	typedef unsigned __int32  uint32;
	typedef signed __int32      sint32;

	// 16-bit ints, guaranteed to be 2 bytes in size
	typedef unsigned __int16  uint16;
	typedef signed __int16      sint16;

	// 8-bit ints, guaranteed to be 1 byte in size
	typedef unsigned __int8   uint8;
	typedef signed __int8       sint8;
#...
I realize that this is a pain but keep in mind that int x; on one compiler might be 4 bytes, and on another 8 bytes or worse 2 bytes, by using specific typedefs assigning exactly what we want it to be will produce more osund code and make debugging later alot easier when we don't need to worry about weather or not variables are correctly sized and so on.

Anyhow thats a few suggestions, i'am currently working on getting this to recompile under vs 2005, since i tossed the changes i had last time. I hope to be able to submit to you modifications so that I don't need to keep doing this each time you release an updated verision.

++Cire.

User avatar
zuzuf
Administrateur - Site Admin
Posts: 3281
Joined: Mon Oct 30, 2006 8:49 pm
Location: Toulouse, France
Contact:

Post by zuzuf » Fri Nov 10, 2006 10:26 pm

#1 yes the GNU compiler supports #pragma

#2 I never used namespaces, but if you want to use namespaces I see nothing against it
just see what the rest of the team thinks about it

#3 We could define things like TA3D_PLATFORM_ARCH_LINUX, it would make the code easier to read (since it already uses platform specific code)

#4 Because TA3D can be built on more than one platform and will be ported to more platforms, we will need to control type size. I already had errors on x86_64 linux because sizeof(long)=8 on this platform and not 4!! In TA3D's current code, we expect a short to be 2 bytes, a int 4 and long is not used.

I didn't try building TA3D with VS2005, but I know it won"t work on VC++ 6 because VC++6 doesn't handle this properly:

Code: Select all

for(int i=0;i<10>=0;i--) { ... }

it will say i is declared twice, and this scheme occurs very often in the code
=>;-D Penguin Powered

Post Reply

Who is online

Users browsing this forum: No registered users and 36 guests