Go Back   EQEmulator Home > EQEmulator Forums > Development > Development::Development

Development::Development Forum for development topics and for those interested in EQEMu development. (Not a support forum)

Reply
 
Thread Tools Display Modes
  #1  
Old 06-10-2009, 02:42 PM
Shendare
Dragon
 
Join Date: Apr 2009
Location: California
Posts: 814
Default

My understanding is that most of the problems 64-bit compiling is going to run into are going to be type definition differences. For example, an "int" is 32 bits wide in a 32-bit environment, but 64 bits wide in a 64-bit environment. Pointers are also going to be 64 bits wide instead of 32.

This means that any struct that contains an int is going to be incorrectly sized and misaligned in an environment it wasn't designed for.

The cleanest and easiest way to avoid screwing up your structs and such between 32-bit and 64-bit environments would be to change any references to non-static data types ("short", "int", "long", etc.) to static references.

I believe gcpp uses "int16_t", "int32_t", "int64_t", etc. for its static integer types, defined in <stdint.h> or something. Not really sure.

Visual C++ (the environment I'm accustomed to) uses __int16, __int32, __int64 for its static types.

What I generally do in my own code is define a set of static typedefs for maximum portability:

typedef signed __int32 sint32;
typedef unsigned __int32 uint32;
typedef signed __int16 sint16;
typedef unsigned __int16 uint16;
typedef signed __int8 sint8;
typedef unsigned __int8 uint8;

etc.

Of course, coming from an assembly background, I also tend to use BYTE, WORD, DWORD, and QWORD for the unsigned integer types.

The gist of it is that these variables will retain their original size no matter what environment they're in, 32-bit, 64-bit, 128-bit, whatever.

It may be a simple matter of using #ifdef directives to set the appropriate typedefs for each C++ compiler environment (gcpp, Visual Studio, etc.)...

Code:
#ifdef (a gcpp-only define)
typedef int32_t  sint32;
typedef uint32_t uint32;
#endif
#ifdef (a vcpp-only define, __CLR_VER maybe?)
typedef signed __int32 sint32;
typedef unsigned __int32 uint32;
#endif
Then doing a search-and-replace to change all references to the non-static types into the static types.

Just my 2 coppers.

- Shendare
Reply With Quote
  #2  
Old 06-10-2009, 02:58 PM
KLS
Administrator
 
Join Date: Sep 2006
Posts: 1,348
Default

Personally, if you can avoid ifdef blocks and just make code that works on both platforms that's best. If it's unavoidable then it's unavoidable though. I definitely think the code looks best without 10 million ifdef blocks all over it /glare bot code.

I can't imagine there are too many changes that will break 32 bit compatibility. Maybe a few but we've got enough 32 bit developers to catch it pretty quickly.
Reply With Quote
  #3  
Old 06-10-2009, 03:19 PM
gaeorn
Developer
 
Join Date: Apr 2009
Location: USA
Posts: 478
Default

Quote:
Originally Posted by KLS View Post
Personally, if you can avoid ifdef blocks and just make code that works on both platforms that's best. If it's unavoidable then it's unavoidable though. I definitely think the code looks best without 10 million ifdef blocks all over it /glare bot code.
That's what I suspected. As long as it works on both, it makes it easier to maintain (not to mention readability). And maybe the new bot code WildcardX is working on won't require the ifdef blocks (crosses fingers).

Quote:
I can't imagine there are too many changes that will break 32 bit compatibility. Maybe a few but we've got enough 32 bit developers to catch it pretty quickly.
I felt this way as well, but since I'm relatively new to the project, I wanted to defer to those who have worked a lot longer on it.

I'll start submitting some diffs in the next day or so.
Reply With Quote
  #4  
Old 06-10-2009, 03:02 PM
gaeorn
Developer
 
Join Date: Apr 2009
Location: USA
Posts: 478
Default

Thankfully the majority of the code already uses uint32, uint16 and uint8 (if not all of it). The type casting has thus far only been needed for printf formats using %lu when being fed a uint32.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 08:54 AM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3