Thread: Please STICKY this- vital to MSVC 6 dev - BASETSD.h

  1. #1
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607

    Please STICKY this- vital to MSVC 6 dev - BASETSD.h

    It seems that MS Assumes that we are going to be using MSVC .NET to develop DirectX apps on. Wrong assumption MS.

    You must have the basetsd.h file in your DirectX SDK include directory. Unfortunately its only available in the MS Platform SDK. So you can either download that or copy this from here. This solution was provided by Derek Smart, developer of the Battlecruiser, and the recent Battlecruiser Millenium series. I found the solution on another forums - but I won't spam it here.

    basetsd.h
    Code:
    /*++ 
    Copyright (c) Microsoft Corporation.  All rights reserved. 
    Module Name: 
    	basetsd.h 
    Abstract: 
    	Type definitions for the basic sized types. 
    Author: 
    Revision History: 
    --*/ 
    #ifndef _BASETSD_H_ 
    #define _BASETSD_H_ 
    #if _MSC_VER > 1000 
    #pragma once 
    #endif 
    #ifdef __cplusplus 
    extern "C" { 
    #endif 
    typedef signed char		 INT8, *PINT8; 
    typedef signed short		INT16, *PINT16; 
    typedef signed int		  INT32, *PINT32; 
    typedef signed __int64	  INT64, *PINT64; 
    typedef unsigned char	   UINT8, *PUINT8; 
    typedef unsigned short	  UINT16, *PUINT16; 
    typedef unsigned int		UINT32, *PUINT32; 
    typedef unsigned __int64	UINT64, *PUINT64; 
    // 
    // The following types are guaranteed to be signed and 32 bits wide. 
    // 
    typedef signed int LONG32, *PLONG32; 
    // 
    // The following types are guaranteed to be unsigned and 32 bits wide. 
    // 
    typedef unsigned int ULONG32, *PULONG32; 
    typedef unsigned int DWORD32, *PDWORD32; 
    #if !defined(_W64) 
    #if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300 
    #define _W64 __w64 
    #else 
    #define _W64 
    #endif 
    #endif 
    // 
    // The INT_PTR is guaranteed to be the same size as a pointer.  Its 
    // size with change with pointer size (32/64).  It should be used 
    // anywhere that a pointer is cast to an integer type. UINT_PTR is 
    // the unsigned variation. 
    // 
    // __int3264 is intrinsic to 64b MIDL but not to old MIDL or to C compiler. 
    // 
    #if ( 501 < __midl ) 
    	typedef [public] __int3264 INT_PTR, *PINT_PTR; 
    	typedef [public] unsigned __int3264 UINT_PTR, *PUINT_PTR; 
    	typedef [public] __int3264 LONG_PTR, *PLONG_PTR; 
    	typedef [public] unsigned __int3264 ULONG_PTR, *PULONG_PTR; 
    #else  // midl64 
    // old midl and C++ compiler 
    #if defined(_WIN64) 
    	typedef __int64 INT_PTR, *PINT_PTR; 
    	typedef unsigned __int64 UINT_PTR, *PUINT_PTR; 
    	typedef __int64 LONG_PTR, *PLONG_PTR; 
    	typedef unsigned __int64 ULONG_PTR, *PULONG_PTR; 
    	#define __int3264   __int64 
    #else 
    	typedef _W64 int INT_PTR, *PINT_PTR; 
    	typedef _W64 unsigned int UINT_PTR, *PUINT_PTR; 
    	typedef _W64 long LONG_PTR, *PLONG_PTR; 
    	typedef _W64 unsigned long ULONG_PTR, *PULONG_PTR; 
    	#define __int3264   __int32 
    #endif 
    #endif // midl64 
    // 
    // HALF_PTR is half the size of a pointer it intended for use with 
    // within structures which contain a pointer and two small fields. 
    // UHALF_PTR is the unsigned variation. 
    // 
    #ifdef _WIN64 
    #define ADDRESS_TAG_BIT 0x40000000000UI64 
    typedef __int64 SHANDLE_PTR; 
    typedef unsigned __int64 HANDLE_PTR; 
    typedef unsigned int UHALF_PTR, *PUHALF_PTR; 
    typedef int HALF_PTR, *PHALF_PTR; 
    #if !defined(__midl) 
    __inline 
    unsigned long 
    HandleToULong( 
    	const void *h 
    	) 
    { 
    	return((unsigned long) (ULONG_PTR) h ); 
    } 
    __inline 
    long 
    HandleToLong( 
    	const void *h 
    	) 
    { 
    	return((long) (LONG_PTR) h ); 
    } 
    __inline 
    void * 
    ULongToHandle( 
    	const unsigned long h 
    	) 
    { 
    	return((void *) (UINT_PTR) h ); 
    } 
    
    __inline 
    void * 
    LongToHandle( 
    	const long h 
    	) 
    { 
    	return((void *) (INT_PTR) h ); 
    } 
    
    __inline 
    unsigned long 
    PtrToUlong( 
    	const void  *p 
    	) 
    { 
    	return((unsigned long) (ULONG_PTR) p ); 
    } 
    __inline 
    unsigned int 
    PtrToUint( 
    	const void  *p 
    	) 
    { 
    	return((unsigned int) (UINT_PTR) p ); 
    } 
    __inline 
    unsigned short 
    PtrToUshort( 
    	const void  *p 
    	) 
    { 
    	return((unsigned short) (unsigned long) (ULONG_PTR) p ); 
    } 
    __inline 
    long 
    PtrToLong( 
    	const void  *p 
    	) 
    { 
    	return((long) (LONG_PTR) p ); 
    } 
    __inline 
    int 
    PtrToInt( 
    	const void  *p 
    	) 
    { 
    	return((int) (INT_PTR) p ); 
    } 
    __inline 
    short 
    PtrToShort( 
    	const void  *p 
    	) 
    { 
    	return((short) (long) (LONG_PTR) p ); 
    } 
    __inline 
    void * 
    IntToPtr( 
    	const int i 
    	) 
    // Caution: IntToPtr() sign-extends the int value. 
    { 
    	return( (void *)(INT_PTR)i ); 
    } 
    __inline 
    void * 
    UIntToPtr( 
    	const unsigned int ui 
    	) 
    // Caution: UIntToPtr() zero-extends the unsigned int value. 
    { 
    	return( (void *)(UINT_PTR)ui ); 
    } 
    __inline 
    void * 
    LongToPtr( 
    	const long l 
    	) 
    // Caution: LongToPtr() sign-extends the long value. 
    { 
    	return( (void *)(LONG_PTR)l ); 
    } 
    __inline 
    void * 
    ULongToPtr( 
    	const unsigned long ul 
    	) 
    // Caution: ULongToPtr() zero-extends the unsigned long value. 
    { 
    	return( (void *)(ULONG_PTR)ul ); 
    } 
    #endif // !_midl 
    #else  // !_WIN64 
    #define ADDRESS_TAG_BIT 0x80000000UL 
    typedef unsigned short UHALF_PTR, *PUHALF_PTR; 
    typedef short HALF_PTR, *PHALF_PTR; 
    typedef _W64 long SHANDLE_PTR; 
    typedef _W64 unsigned long HANDLE_PTR; 
    #define HandleToULong( h ) ((ULONG)(ULONG_PTR)(h) ) 
    #define HandleToLong( h )  ((LONG)(LONG_PTR) (h) ) 
    #define ULongToHandle( ul ) ((HANDLE)(ULONG_PTR) (ul) ) 
    #define LongToHandle( h )   ((HANDLE)(LONG_PTR) (h) ) 
    #define PtrToUlong( p ) ((ULONG)(ULONG_PTR) (p) ) 
    #define PtrToLong( p )  ((LONG)(LONG_PTR) (p) ) 
    #define PtrToUint( p ) ((UINT)(UINT_PTR) (p) ) 
    #define PtrToInt( p )  ((INT)(INT_PTR) (p) ) 
    #define PtrToUshort( p ) ((unsigned short)(ULONG_PTR)(p) ) 
    #define PtrToShort( p )  ((short)(LONG_PTR)(p) ) 
    #define IntToPtr( i )	((VOID *)(INT_PTR)((int)i)) 
    #define UIntToPtr( ui )  ((VOID *)(UINT_PTR)((unsigned int)ui)) 
    #define LongToPtr( l )   ((VOID *)(LONG_PTR)((long)l)) 
    #define ULongToPtr( ul ) ((VOID *)(ULONG_PTR)((unsigned long)ul)) 
    #endif // !_WIN64 
    #define HandleToUlong(h)  HandleToULong(h) 
    #define UlongToHandle(ul) ULongToHandle(ul) 
    #define UlongToPtr(ul) ULongToPtr(ul) 
    #define UintToPtr(ui)  UIntToPtr(ui) 
    #define MAXUINT_PTR  (~((UINT_PTR)0)) 
    #define MAXINT_PTR   ((INT_PTR)(MAXUINT_PTR >> 1)) 
    #define MININT_PTR   (~MAXINT_PTR) 
    #define MAXULONG_PTR (~((ULONG_PTR)0)) 
    #define MAXLONG_PTR  ((LONG_PTR)(MAXULONG_PTR >> 1)) 
    #define MINLONG_PTR  (~MAXLONG_PTR) 
    #define MAXUHALF_PTR ((UHALF_PTR)~0) 
    #define MAXHALF_PTR  ((HALF_PTR)(MAXUHALF_PTR >> 1)) 
    #define MINHALF_PTR  (~MAXHALF_PTR) 
    // 
    // SIZE_T used for counts or ranges which need to span the range of 
    // of a pointer.  SSIZE_T is the signed variation. 
    // 
    typedef ULONG_PTR SIZE_T, *PSIZE_T; 
    typedef LONG_PTR SSIZE_T, *PSSIZE_T; 
    // 
    // Add Windows flavor DWORD_PTR types 
    // 
    typedef ULONG_PTR DWORD_PTR, *PDWORD_PTR; 
    // 
    // The following types are guaranteed to be signed and 64 bits wide. 
    // 
    typedef __int64 LONG64, *PLONG64; 
    
    // 
    // The following types are guaranteed to be unsigned and 64 bits wide. 
    // 
    typedef unsigned __int64 ULONG64, *PULONG64; 
    typedef unsigned __int64 DWORD64, *PDWORD64; 
    // 
    // Thread affinity. 
    // 
    typedef ULONG_PTR KAFFINITY; 
    typedef KAFFINITY *PKAFFINITY; 
    #ifdef __cplusplus 
    } 
    #endif 
    #endif // _BASETSD_H_
    If you are using MSVC you MUST MUST MUST have this in your dxsdk\include folder.
    You also MUST MUST MUST link with the d3dx9.lib version found in the summer2004xtras folder. I'm sure the October release comes with it as well.
    Last edited by VirtualAce; 12-07-2004 at 09:27 AM.

  2. #2
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    C'mon, bubba. You forgot the code tags.
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  3. #3
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    It aint working.

    I copied it from another post and it messed it up.

    Stupid thing. I fixed it. You can't copy from a code section into another or it messed it all up on the board. I just pasted it from MSVC.
    Last edited by VirtualAce; 12-07-2004 at 09:28 AM.

  4. #4
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072
    So the DX9 SDK doesn't work on VC6? Nice work Microsoft. Although I would just comment out the basetsd.h header and define the PTR types myself.
    Copyright (c) Microsoft Corporation.
    Is it legal to post here? I guess no one will complain, but still.
    Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling

  5. #5
    Banned
    Join Date
    Oct 2004
    Posts
    250
    well i have been uisng the DX9 SDK for some time with VC6 and had no problems :/

  6. #6
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    Anything after the Summer 2004 SDK release will not natively work with MSVC 6. All prior releases will.

    It is ok to post it here because it is a header to be used by programmers. The copyright and all information relevant to the source code provider are in the header. This header used to come with DirectX but now only comes with the Platform SDK. It's not like it's supposed to be inaccessible to programmers - it is a header you must use.

    I would not define the types myself - clearly this header does more than just define a few data types. As always one data type relies on another and so on. Use the header.

  7. #7
    Banned
    Join Date
    Oct 2004
    Posts
    250
    ah ok maybe this is another attempt by MicroSoft to force you to use .NET

  8. #8
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    This needs to be stickied - please. Without this file you cannot compile anything for DirectX 9.0 Summer 04 + inside of MSVC 6. And sometimes the Platform SDK won't install it on certain machines due to several internal checks that the install program does concerning your OS version.

    Please sticky this or place it somewhere where people can download it and use it. Since the copyright info is included and the code is freely available from MS (given your Platform SDK installs correctly) I do not believe that it violates any laws.

  9. #9
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072
    PM webmaster and ask him to put it in the FAQ instead.
    Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling

  10. #10
    Software Developer jverkoey's Avatar
    Join Date
    Feb 2003
    Location
    New York
    Posts
    1,905
    Nobody really reads the FAQ...c'mon, when's the last time you checked it?

    I can't say I've ever honestly read anything from there.....well, maybe once, but that's about it.

    The FAQ's more for the new people who ask questions like "reading in to an array" or "flipping a string" stuff....this is a bit more important than that (in my opinion).

  11. #11
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    Yeah this goes way beyond flipping a string or manipulating bits. If you don't have this file, you cannot compile anything under MSVC 6 that makes use of the DirectX SDK's Summer 2004 and beyond.

    Period.

  12. #12
    Grammar Police HybridM's Avatar
    Join Date
    Jan 2003
    Posts
    355
    I'd thank Derek Smart, but he's the biggest idiot on the Internet, and that's a big call I know.

    I suppose this is an effort by MS to phase out MSVC 6, but it seems to me that the majority of the community still uses 6. 6 is the most easily obtainable by less-than-legal means, but I'm sure that's not what accounts for that majority. Visual Studio is expensive software.

    I'm glad there's a solution for this. It wouldn't be difficult for MS to update this file on MSVC 6 installations when installing DX though, surely?
    Thor's self help tip:
    Maybe a neighbor is tossing leaf clippings on your lawn, looking at your woman, or harboring desires regarding your longboat. You enslave his children, set his house on fire. He shall not bother you again.

    OS: Windows XP
    Compiler: MSVC

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. BASETSD.h
    By Rismay in forum Game Programming
    Replies: 3
    Last Post: 08-11-2005, 07:29 PM