UINT, LONG vs. unsigned, long 
Author Message
 UINT, LONG vs. unsigned, long

Operating System independent!!

--

--------------------------
Smile Seo

Techincal Staff of 4C Soft,Inc.( http://www.*-*-*.com/ )
C.C. 4th member in Ajou Univ.( http://www.*-*-*.com/ )

Homepage : http://www.*-*-*.com/
Bugfree Site : http://www.*-*-*.com/

H.P. : 011-9642-4115
Tel. : +82-2-544-2822


Quote:
> What is the advantage of using UINT, LONG, ... instead of unsigned int,
> long, ...?
> Thanks.



Sun, 01 Dec 2002 03:00:00 GMT  
 UINT, LONG vs. unsigned, long
Can you please explain it in more details?

Thanks
- Predrag Grkovic.


Quote:
> Operating System independent!!

> --

> --------------------------
> Smile Seo

> Techincal Staff of 4C Soft,Inc.(http://www.4csoft.com)
> C.C. 4th member in Ajou Univ.(http://acc.ajou.ac.kr)

> Homepage : http://go.to/smileseo
> Bugfree Site : http://www.egroups.com/subscribe/bugfree

> H.P. : 011-9642-4115
> Tel. : +82-2-544-2822



> > What is the advantage of using UINT, LONG, ... instead of unsigned int,
> > long, ...?
> > Thanks.



Mon, 02 Dec 2002 03:00:00 GMT  
 UINT, LONG vs. unsigned, long
a UINT is defined differently for win32, win16 (historically) and win64
(looking forward), but when used in an API declaration, they are all the
same (unisigned int in Win32)

The other example, LONG, currently is 32 bits (long), with Win64, a 'long'
will have to be at least 64 bits, but a LONG must stay the same...

Quote:

> Can you please explain it in more details?


> > Operating System independent!!


> > > What is the advantage of using UINT, LONG, ... instead of unsigned
int,
> > > long, ...?



Mon, 02 Dec 2002 03:00:00 GMT  
 UINT, LONG vs. unsigned, long

Quote:

> The other example, LONG, currently is 32 bits (long), with Win64, a
> 'long' will have to be at least 64 bits, but a LONG must stay the
> same...

I have bad news for you there. 'long' is 32 bits on Win64. 'long long' is
64 bits.

---

          "C++ - the fortran of the early 21st century."



Mon, 02 Dec 2002 03:00:00 GMT  
 UINT, LONG vs. unsigned, long
OK.
sizeof(long)==4 (bytes) in win32
sizeof(long)==8 (bytes) in win64
sizeof(LONG)==4 (bytes) in win32
sizeof(LONG)==4 (bytes) in win64

1. Why would anyone want for LONG to be 'half' of long in win64? (I think
that very few programs depends on the size of its' variables and would crash
when long would become twice as 'bigger'. So, I think that more people would
like their longs to become twice as bigger when they recompile their
programs for win64.)
2. Wouldn't it be very athwart for LONG and long to be different types in
win64? Will Microsoft introduce LONG64 to be equal type with long?
3. The same goes for function declarations: every win32 API function is
declared with these UPPERCASE types. Does this mean that win64 API will have
CreateThread with 'old' win32 types and CreateThread64 or CreateThread2 with
'new' win64 types?

I'm a little bit confused about all this.

Thanks to everybody trying to resolve these things up to me.

- Predrag Grkovic.


Quote:
> a UINT is defined differently for win32, win16 (historically) and win64
> (looking forward), but when used in an API declaration, they are all the
> same (unisigned int in Win32)

> The other example, LONG, currently is 32 bits (long), with Win64, a 'long'
> will have to be at least 64 bits, but a LONG must stay the same...


> > Can you please explain it in more details?


> > > Operating System independent!!


> > > > What is the advantage of using UINT, LONG, ... instead of unsigned
> int,
> > > > long, ...?



Mon, 02 Dec 2002 03:00:00 GMT  
 UINT, LONG vs. unsigned, long

Quote:

> OK.
> sizeof(long)==4 (bytes) in win32
> sizeof(long)==8 (bytes) in win64
> sizeof(LONG)==4 (bytes) in win32
> sizeof(LONG)==4 (bytes) in win64

> 1. Why would anyone want for LONG to be 'half' of long in win64? (I think
> that very few programs depends on the size of its' variables and would
crash
> when long would become twice as 'bigger'. So, I think that more people
would
> like their longs to become twice as bigger when they recompile their
> programs for win64.)

LONG must have a fixed length for as long as it's used (otherwise API
declarations go straight out the window), so a LONG will always be 4 bytes.
(this would be easier to explain with an int, but never mind)

Quote:
> 2. Wouldn't it be very athwart for LONG and long to be different types in
> win64? Will Microsoft introduce LONG64 to be equal type with long?

Although I've not seen any of the documention for Win64, I'd assume there
will be a LONG64 at some point (or DLONG)

Quote:
> 3. The same goes for function declarations: every win32 API function is
> declared with these UPPERCASE types. Does this mean that win64 API will
have
> CreateThread with 'old' win32 types and CreateThread64 or CreateThread2
with
> 'new' win64 types?

Why would it need to? this is the point of the uppercase types, so:
HANDLE CreateThread( LPSECURITY_ATTRIBUTES, DWORD, LPTHREAD_START_ROUTINE,
LPVOID, DWORD, LPDWORD );
will always hold true -- even if the underlying processor architecture is
different.

A classic example of how it's already happening is the DWORD type.
Originally of double word length, with current processor arcitectures, it's
actually defined as being the same length as a 'word' or 'long' or 'int'...

(In the great naming tradition, I'd assume it's successor to be called
CreateThreadEx)

Quote:
> I'm a little bit confused about all this.

> Thanks to everybody trying to resolve these things up to me.

Hope this helps :)


Sun, 08 Dec 2002 03:00:00 GMT  
 UINT, LONG vs. unsigned, long
Hello,

Quote:
> Although I've not seen any of the documention for Win64, I'd assume there

will be a LONG64 at some point (or DLONG)

there are already defined types for representing 64-bit integers in Windows
API - LONGLONG, ULONGLONG (DWORDLONG) that use Microsoft compilers specific
"__int64" type - you can use large integers in 32-bit environment, but
operations are compiled as inline asm functions (a little slow down :-) - in
Win64 it would be direct 64-bit registers operations...

So, Predrag, as Rowland says, using types LONGLONG, DWORD, UINT, CHAR,
BYTE... will make your program platform independent and you will always
know, what is the exact size of type...

Also, using TCHAR/LPTSTR instead of char/char* would save you a lot of time
if you plan to use UNICODE...

Best regards,
--
ChainsaW

P.S. Note, that compiler usually produces highly optimized code, where CHAR
occupies whole 32-bit processor register, because operations with whole
registers are much more faster... Also, data aligning is the reason, why
sizeof(structure) may != sum of sizeofs mebers... (see the 2nd NG message
below)



Sun, 08 Dec 2002 03:00:00 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. long vs unsigned long

2. char size (was long long long long long int)

3. format specifier for unsigned long long

4. printing unsigned long long problem

5. unsigned long long int

6. long long long long integers

7. unsigned long to long without lossage (Help)

8. long long vs. __int64

9. (unsigned int)(unsigned long)(void *)p

10. How to convert unsigned long to unsigned char?

11. Converting Unsigned Short to Unsigned long

12. short/long/long long Formatting questions

 

 
Powered by phpBB® Forum Software