Skip to main content
gamedev.net
🔒 Locked

long long

Started by Nullio Nov 25, 2003 at 4:22 PM 5 replies 1.1k views
Original Post
Nullio
Nullio
in Visual Studio 2002 .NET I can''t seem to declare a long long variable. I know you can do it with other compilers and I need to declare them for a cmput science project. Is there a way I can enable them?
Nullio
Nullio
Ok thanks I''ll just use that then, but incase I''m require to use a long long as part of the assignment is there anyway I can make it work possiblily typedef or something?
levendis
levendis
long long isn''t a part of C++, it''s a gcc addin. You can #ifdef for GCC in your code and use long long or __int64 depending on platform. Or since you''re using visual studio just ctrl-h all references before you submit it.

I don''t think there''s an easy way to perform a typedef with a space through any preprocessor.
------http://www.livejournal.com/users/rain_is_wet/
aboeing
aboeing

#if defined(_MSC_VER) || defined(__LCC__) || defined(__INTEL_COMPILER)

#if defined(WIN32)
typedef unsigned long DWORD;
typedef unsigned char BYTE;
typedef unsigned short WORD;
typedef unsigned __int64 QWORD;

#include <basetsd.h>
#else
typedef unsigned __int8 BYTE;
typedef unsigned __int16 WORD;
typedef unsigned __int32 DWORD;
typedef unsigned __int64 QWORD;
typedef signed __int8 INT8;
typedef signed __int16 INT16;
typedef signed __int32 INT32;
typedef signed __int64 INT64;
typedef unsigned __int32 UINT32;
#endif

#elif defined(__GNUC__) || defined(__MWERKS__) || defined(__SUNPRO_C) || defined(__DMC__)

typedef unsigned char BYTE;
typedef unsigned short WORD;
typedef unsigned long DWORD;
typedef unsigned long long QWORD;

typedef signed char INT8;
typedef signed short INT16;
typedef signed int INT32;
typedef signed long long INT64;
typedef unsigned int UINT32;

#else
//im just guessing here! - these are not going to be right.

//#error Dont know word sizes for these machines/compilers

typedef unsigned char BYTE;
typedef unsigned short WORD;
typedef unsigned long DWORD;
typedef struct {DWORD a, b;} QWORD;
typedef signed char INT8;
typedef signed short INT16;
typedef signed int INT32;
typedef unsigned int UINT32;
#endif

there was a template solution on flipcode that ensured you got the correct sized integers iirc. Search for that.

[edited by - aboeing on November 25, 2003 11:23:43 PM]
hplus0603
hplus0603
If you need to guess for sizes, "unsigned int" is very likely 32 bits, and "unsigned long" can be 32 or 64, depending on programming model. The 16-bit model is luckily 10 years in the past for all but 0.001% of us :-)

(lp64 == long and pointer are 64 bits == The One True Way)
enum Bool { True, False, FileNotFound };

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.