-
January 25th, 2002, 08:56 PM
#1
[RESOLVED] Windows API data types + LPCBYTE
Can anyone tell me what an LPCBYTE is (found reading through someones code) and how it differs from a long pointer to byte LPBYTE? It doesn't seem to be part of the windows api ...
A more general question - is there a simple reason why windows defines its own versions of the basic types (char as BYTE, short as WORD, long as DWORD).. and more importantly why you should use them?
Many thanks in advance
-
January 25th, 2002, 11:02 PM
#2
Re: Windows API data types + LPCBYTE
LPCBYTE is a const LPBYTE or a const char * (as defined in ODBCSS.H)
The API used its own defines so that it can remain consistent across all supported platforms. A WORD on a 16-bit platform, should be the same size as a WORD on a 64-bit platform (both 16-bit unsigned integers), whereas an int value is entirely different (16 vs 64).
Hope this helps,
- Nigel
-
March 8th, 2018, 04:12 AM
#3
Re: Windows API data types + LPCBYTE
Originally Posted by NigelQ
LPCBYTE is a const LPBYTE
This information is wrong LPCBYTE is not const LPBYTE! This makes the pointer itself constant not the value pointed to!
Even const char* is the wrong track. BYTE should be unsigned, so const unsigned char* or const BYTE * (if windows.h is included) may be a way.
PS: I know that the thread is old, but wrong information should be corrected (Just my 2 cents).
-
March 8th, 2018, 07:18 AM
#4
Re: Windows API data types + LPCBYTE
Yes, I agree that wrong information should be corrected.
LPCBYTE is defined as
Code:
typedef const BYTE *LPCBYTE;
with BYTE defined as
Code:
typedef unsigned char BYTE;
Hence LPCBYTE is actually
Code:
typedef const unsigned char* LPCBYTE;
which can be changed to be
Code:
typedef unsigned char const * LPCBYTE;
which can be read from right to left as
a pointer to const unsigned char. ie a non-const pointer to const memory of type unsigned char.
If it was a const pointer to non-const memory then the definition would be
Code:
typedef BYTE * const CLPBYTE;
which, from right to left, is const pointer to non-const BYTE (unsigned char).
For a const pointer to const memory, it would be
Code:
typedef BYTE const * const CLPCBYTE;
or
Code:
typedef const BYTE * const CLPCBYTE;
ie const pointer to const BYTE data.
Last edited by 2kaud; March 8th, 2018 at 07:24 AM.
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|