Re: Using strsafe.h and va_list

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

From: Nikolaos D. Bougalis (nikb_at_webmaster.com)
Date: 05/26/04


Date: Wed, 26 May 2004 03:23:52 -0700

Tim wrote:

> sizeof expression
>
> The sizeof keyword gives the amount of storage, in bytes, associated with a
> variable or a type (including aggregate types). This keyword returns a value
> of type size_t.

        You seem to not read my code very well:

#define tchar_size(x) (sizeof(x) / sizeof(TCHAR))

        Let's assume this:

        TCHAR buf[512];

        In UNICODE builds, tchar_size(buf) expands to: (sizeof(buf) /
sizeof(TCHAR)) which is (1024 / 2) or 512.

        In non-UNICODE builds, tchar_size(buf) expands to (sizeof(buf) /
sizeof(CHAR)) which is (512 / 1) or 512.

        Any questions?

        -n

        



Relevant Pages

  • Re: Using strsafe.h and va_list
    ... > The sizeof keyword gives the amount of storage, in bytes, associated with a ... > variable or a type (including aggregate types). ...
    (microsoft.public.vc.mfc)
  • Re: Using strsafe.h and va_list
    ... > Tim wrote: ... >> The sizeof keyword gives the amount of storage, in bytes, associated with ... >> a variable or a type (including aggregate types). ...
    (microsoft.public.vc.mfc.docview)
  • Re: Using strsafe.h and va_list
    ... > Tim wrote: ... >> The sizeof keyword gives the amount of storage, in bytes, associated with ... >> a variable or a type (including aggregate types). ...
    (microsoft.public.vc.mfc)