tags:

views:

104

answers:

4

I have a C++ program that uses LPDWORD, DWORD, etc. When I compile using GCC, it throws an error. How do I handle LPDWORD, DWORD, LPBYTE, and LPTSTR in GCC?

+1  A: 

If you're on a Windows system, you can use

#include <windows.h>

These datatypes are typical Windows API datatypes.

If you're on another platform, you can typedef the datatypes, but it's likely that the problems will go on and you'll have to port much of the code.

schnaader
+6  A: 
typedef uint32_t* LPDWORD;
typedef uint32_t DWORD;
// etc
Kirill V. Lyadvinsky
thanks for your response, for LPSTR, LPBYTE ?
JKS
`typedef char* LPSTR; typedef unsigned char* LPBYTE;`
Kirill V. Lyadvinsky
very very thank you
JKS
+2  A: 

All of those typedefs are Microsoft's version of the GCC's typedefs. If you only have some of them in your program, you can add a header file to convert them into GCC's semantics.

See this MSDN page for more info on Microsoft's data types:

http://msdn.microsoft.com/en-us/library/aa383751(VS.85).aspx

Bob Fincheimer
+4  A: 

Those are types defined in the Windows specific header file windows.h. If your code uses those types, it probably uses a lot of Windows specific functions too, and thus will not be portable. That's not to say you can't compile such code with GCC - you can with the MinGW port, but this will only work on Windows.

anon
Actually these types are defined in windev.h. Including windows.h gives you the types but you get a lot of additional declarations you won't need.
harper
@harper If you don't call the functions, I don't see why you need the types.
anon
Sure, you have to include all header files for appropriate prototypes. But feel free to use the type BYTE for something that is just a byte independent of the operating system or any specific function.But Suriyan Suresh asked just for support for these types. No missing function prototypes were noticed. So it's less work to look at that file, that holds the definitions.
harper