Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > DWORD and bool to binary

Reply
Thread Tools

DWORD and bool to binary

 
 
ahso
Guest
Posts: n/a
 
      11-26-2009
Hi
any ideas on what to change?

if (ddsd.ddpfPixelFormat.dwFourCC == FOURCC_DXT1)
{
etc.
I get: "invalid operands of types ‘DWORD’ and ‘bool’ to binary
‘operator|’"
Many thanks
Michael Sgier
 
Reply With Quote
 
 
 
 
Fred Zwarts
Guest
Posts: n/a
 
      11-26-2009
ahso <> typed
(in 8aa1e993-c34a-46bd-9664-e225b5539532...oglegroups.com)
> Hi
> any ideas on what to change?
>
> if (ddsd.ddpfPixelFormat.dwFourCC == FOURCC_DXT1)
> {
> etc.
> I get: "invalid operands of types ‘DWORD’ and ‘bool’ to binary
> ‘operator|’"
> Many thanks
> Michael Sgier


You did not supply enough information.
Please, reduce your problem to a minimal program that can be compiled,
so that we can help you.
How should we know what ddsd is? etc.
The error message suggest that a bool type and a DWORD type are involved.
The fact that FOURCC_DXT1 is all uppercase, suggests that it is a preprocessor macro.
Probably there is an error in this macro, or it is use incorrectly.
 
Reply With Quote
 
 
 
 
ahso
Guest
Posts: n/a
 
      11-26-2009
Hi Fred

// To avoid having to include DirectX headers in the FlyLegacy
development environment,
// the DDSURFACEDESC2 struct definition is copied here from ddraw.h
//
#ifndef MAKEFOURCC
#define MAKEFOURCC(ch0, ch1, ch2,
ch3) \
((DWORD)(BYTE)(ch0) | ((DWORD)(BYTE)(ch1) < | \
((DWORD)(BYTE)(ch2) < 16) | ((DWORD)(BYTE)(ch3) <
24 ))
#endif //defined(MAKEFOURCC)

/*
* FOURCC codes for DX compressed-texture pixel formats
*/
#define FOURCC_DXT1 (MAKEFOURCC('D','X','T','1'))
#define FOURCC_DXT2 (MAKEFOURCC('D','X','T','2'))
#define FOURCC_DXT3 (MAKEFOURCC('D','X','T','3'))
#define FOURCC_DXT4 (MAKEFOURCC('D','X','T','4'))
#define FOURCC_DXT5 (MAKEFOURCC('D','X','T','5'))

....
....
// Read surface descriptor and set relevant class data members
UINT8 factor = 0;
DDSURFACEDESC2 ddsd;
pread (&ddsd, sizeof(ddsd), 1, p);
mipCount = ddsd.dwMipMapCount;
width = ddsd.dwWidth;
height = ddsd.dwHeight;


switch (ddsd.ddpfPixelFormat.dwFourCC)
{
case FOURCC_DXT1:
if (ddsd.dwAlphaBitDepth > 0) {
format = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
} else {
format = GL_COMPRESSED_RGB_S3TC_DXT1_EXT;
}
factor = 2;
break;
case FOURCC_DXT3:
etc.

I reverted to the original switch and get that error now:

.../Utility/ImageDXT.cpp:220: error: duplicate case value
.../Utility/ImageDXT.cpp:212: error: previously used here

Line 212 is the above line with the first case command

Many thanks
Michael
 
Reply With Quote
 
Balog Pal
Guest
Posts: n/a
 
      11-26-2009
"ahso" <>
> // To avoid having to include DirectX headers in the FlyLegacy
> development environment,
> // the DDSURFACEDESC2 struct definition is copied here from ddraw.h
> //
> #ifndef MAKEFOURCC
> #define MAKEFOURCC(ch0, ch1, ch2,
> ch3) \
> ((DWORD)(BYTE)(ch0) | ((DWORD)(BYTE)(ch1) < | \
> ((DWORD)(BYTE)(ch2) < 16) | ((DWORD)(BYTE)(ch3) <
> 24 ))
> #endif //defined(MAKEFOURCC)


this is nonsense, < should definitely be << and if this is wrong anything
else can be too. probably this is abandoned code never compiled with that
conditional.

 
Reply With Quote
 
ahso
Guest
Posts: n/a
 
      11-26-2009
Maybe I did something wrong below? I try to compile that on Linux so I
used typedef.

typedef int DWORD;
typedef unsigned int WORD;
typedef long int LONG;
typedef int BYTE;
typedef bool LPVOID;
 
Reply With Quote
 
ahso
Guest
Posts: n/a
 
      11-26-2009
Hi Balog
true I changed << to < as i got an error about not integer or so. It
compiles on Windows but I want to
compile it for Linux so I used:

typedef int DWORD;
typedef unsigned int WORD;
typedef long int LONG;
typedef int BYTE;
typedef bool LPVOID;

Maybe there's something wrong. I didn't try such before.
Many thanks
Michael
 
Reply With Quote
 
mikethebike
Guest
Posts: n/a
 
      11-26-2009
Balog did u mark me as spam? I had to login as another user for
replying.

Yes I changed << to < as i got some integer error. And yes it compile
on Windows but i want to compile on Linux.
Maybe I made a fault with typedef? Never used that before

typedef int DWORD;
typedef unsigned int WORD;
typedef long int LONG;
typedef int BYTE;
typedef bool LPVOID;

Many thanks
Michael
 
Reply With Quote
 
mikethebike
Guest
Posts: n/a
 
      11-26-2009
Balog did u mark me as spam? I had to login as another user for
replying.

Yes I changed << to < as i got some integer error. And yes it compile
on Windows but i want to compile on Linux.
Maybe I made a fault with typedef? Never used that before

typedef int DWORD;
typedef unsigned int WORD;
typedef long int LONG;
typedef int BYTE;
typedef bool LPVOID;

Many thanks
Michael

 
Reply With Quote
 
ahso
Guest
Posts: n/a
 
      11-26-2009
Balog did u mark me as spam? I had to login as another user for
replying.

Yes I changed << to < as i got some integer error. And yes it compile
on Windows but i want to compile on Linux.
Maybe I made a fault with typedef? Never used that before

typedef int DWORD;
typedef unsigned int WORD;
typedef long int LONG;
typedef int BYTE;
typedef bool LPVOID;

Many thanks
Michael


 
Reply With Quote
 
Richard Herring
Guest
Posts: n/a
 
      11-26-2009
In message
<4dde9616-b259-47f4-8c75->,
mikethebike <> writes
>Balog did u mark me as spam? I had to login as another user for
>replying.
>
>Yes I changed << to < as i got some integer error. And yes it compile
>on Windows but i want to compile on Linux.
>Maybe I made a fault with typedef? Never used that before
>
>typedef int DWORD;
>typedef unsigned int WORD;
>typedef long int LONG;
>typedef int BYTE;
>typedef bool LPVOID;


Trying to make faulty code compile by a sequence of random changes is
not an effective strategy.

*Why* are you inserting random (and almost certainly incorrect - naively
I'd expect DWORD to be Double the length of WORD, and LPVOID to be some
kind of Pointer to VOID) typedefs named to look like macros?

The code was written for an environment which presumably already defines
these symbols, so what is preventing you from compiling it in that
environment? If you're trying to port Windows-specific (and
library-specific) code to a different platform without fully
understanding the differences between platforms, no amount of random
tinkering is likely to succeed.

--
Richard Herring
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
in reply to: DWORD and bool to binary ahso C++ 6 11-27-2009 12:38 AM
convert std::string to (byte*, DWORD) Khuong Dinh Pham C++ 16 08-30-2005 10:34 PM
Is it legal to type cast to DWORD* ??? Denis Remezov C++ 7 07-10-2004 04:44 PM
How do you display DWORD & strings in an Edit Box Xanax C++ 20 09-10-2003 10:48 AM
DWORD date value Lee K C++ 6 07-17-2003 11:19 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57