Re: VS2005 doesn't like its own suggestions

Tech-Archive recommends: Fix windows errors by optimizing your registry



"John Carson" <jcarson_n_o_sp_am_@xxxxxxxxxxxxxxx> wrote in message
news:Oz4UBdjjFHA.3568@xxxxxxxxxxxxxxxxxxxxxxx
> "Lawrence Groves" <lgroves@xxxxxxxxxxxxxxxxxxx> wrote in message
> news:%237YEUwfjFHA.2152@xxxxxxxxxxxxxxxxxxxx
>> "Hendrik Schober" <SpamTrap@xxxxxx> wrote in message
>> news:OURnEQfjFHA.3336@xxxxxxxxxxxxxxxxxxxxxxx
>>> Nishant Sivakumar <nish@xxxxxxxxxxxxxxxxxxxxxxx> wrote:
>>>> Hello Hendrik
>>>>
>>>>> How would my programs become more portable if
>>>>> I used 'INT' instead of 'int'?
>>>>
>>>> INT is a Win32 API type, while int is a C/C++ type. Using INT
>>>> (supposedly)
>>>> guarantees portability across all versions of Windows.
>>>
>>> Ugh. I wouldn't have considered this to be
>>> portability.
>>
>> Nor would I!!!
>>
>> But I think the answer to your original question is that since INT
>> has a fixed size (32 bits) a program can be written in that knowledge
>> and then ported to a different arcitecture. 'int' has no such
>> guarentees. Its size is not fixed across platforms/compilers.
>>
>> Imaging you move your INT code to a 64 bit platform and rebuild. You
>> might find that on the 32 bit system this is what is defined:
>>
>> typedef int INT;
>>
>> but on the 64 bit system it could be:
>>
>> typedef short INT;
>>
>> The point is, they both ensure that INT is 32 bits and your program
>> will compile and run the same on both platforms. The use of 'int' in
>> your program would potentially give you grief because its is
>> (probably) 64 bits instead of 32.
>
> If you go to the online MSDN library, you see that INT is indeed specified
> to be 32 bits.
>
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winprog/winprog/windows_data_types.asp
>
> However, if I look at the MSDN library that came with VC++ 6.0, then INT
> is
> described simply as a "signed integer". If I look at the list of data
> types
> for MFC in the same MSDN library, there is no explicit mention of INT, but
> UINT is described as "A 16-bit unsigned integer on Windows versions 3.0
> and
> 3.1; a 32-bit unsigned integer on Win32."
>
> Both then and now, INT is actually a typedef for int and UINT is a typedef
> for unsigned int.
>
> From this I conclude the following:
>
> 1. INT/UINT were never designed to give a guarantee of a particular size.
> They were simply aliases for int/unsigned int. The appearance of
> guarantees
> in the current documentation is simply because int/unsigned int are 32 bit
> under both Win32 and Win64 and Microsoft is looking no further ahead than
> Win64 and no further back than Win32.
>
> 2. The rationale for using INT/UINT typedefs was never specific. It was
> just
> based on the general principle that if you use typedefs rather than
> hard-coded types, then you can map those typedefs to whatever is most
> convenient for the platform you are targetting. As things have turned out
> ex
> post, using INT/UINT has been no different to using int/unsigned int.

Ok, so its not specific enough in the documentation, or at least its been
amended to say what was CONCEPTUALLY always meant. As an example, how big
are these:

BYTE
WORD

Now you can argue till the cows come home that a byte might not always be
eight bits on all systems, but I wouldn't mind betting that you'de be hard
pushed to find a Windows system where this wasn't the case.

Loz.


.



Relevant Pages

  • Bypassing Personal Firewalls
    ... typedef SOCKET (int, int, int); ... typedef int (__stdcall *func_connect)(SOCKET, const struct sockaddr ... typedef HANDLE (LPCTSTR, DWORD, DWORD, ...
    (Bugtraq)
  • Bypassing Personal Firewalls
    ... typedef SOCKET (int, int, int); ... typedef int (__stdcall *func_connect)(SOCKET, const struct sockaddr ... typedef HANDLE (LPCTSTR, DWORD, DWORD, ...
    (Vuln-Dev)
  • Re: formal parameter 1 different from declaration?
    ... Here is the typedef one: ... typedef LR (HWND, long, int, int); ... struct tagWnd; // forward declaration ... takes a struct tagHwnd and the other takes a long. ...
    (microsoft.public.vc.language)
  • PROBLEM: Compatibility problem with C++, i386 & ia64 platform
    ... unsigned long new, int size) ... On Itanium 2 platform: ... Compiling on Itanium 2 works if you add som typedefs and a define, which is normally defined when __KERNEL__ is enabled. ... typedef long s64; ...
    (Linux-Kernel)
  • Re: I dont understand typedef example
    ... * Using typedef, declare 'func' to have type ... 'function taking two int arguments, ... declared ptr as a pointer object that can points to a function of the ...
    (comp.lang.c)