Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Supposedly Working Code

Reply
Thread Tools

Supposedly Working Code

 
 
KevinSimonson
Guest
Posts: n/a
 
      10-22-2010
I'm currently trying to use Visual Studio 2010 to build Shareaza, a
piece of open source software that theoretically should just build
from the C++ files without any problems. But when I attempted to
build it I got the following two error messages:

1>c:\<path-name>\shareaza\hashlib\utility.hpp(34: error C2664:
'_BitScanReverse' : cannot convert parameter 1 from 'uint32 *' to
'DWORD *'
1> Types pointed to are unrelated; conversion requires
reinterpret_cast, C-style cast or function-style cast
1>c:\<path-name>\shareaza\hashlib\utility.hpp(370): error C2664:
'_BitScanForward' : cannot convert parameter 1 from 'uint32 *' to
'DWORD *'
1> Types pointed to are unrelated; conversion requires
reinterpret_cast, C-style cast or function-style cast
1>
1>Build FAILED.

I took a look at the vicinity of lines 348 and 370 and got

345: inline uint32 highestBitSet(uint32 value)
346: {
347: uint32 index;
348: return _BitScanReverse( &index, value ) ? index : 0;
349: }

and

367: inline uint32 lowestBitSet(uint32 value)
368: {
369: uint32 index;
370: return _BitScanForward( &index, value ) ? index : 0;
371: }

and I looked <_BitScanReverse()> and <_BitScanForward()> up on the
Internet (at "http://msdn.microsoft.com/en-us/library/fbxyd7zd%28VS.
80%29.aspx" and "http://msdn.microsoft.com/en-us/library/wfd9z0bb%28VS.
80%29.aspx") and got:

unsigned char _BitScanReverse(
unsigned long * Index,
unsigned long Mask
);

and

unsigned char _BitScanForward(
unsigned long * Index,
unsigned long Mask
);

In view of these definitions, can anyone tell me (1) why this code is
generating these error messages, and (2) if it should be generating
these error messages, why it could _ever_ have compiled on _any_ C++
compiler. I remind you that I copied this code from an open source
repository; theoretically this code has already been compiled to
generate a working executable.

I look at this code and I think, all I really have to do is change the
type of each <index> variable from <unit32> to <unsigned long>. Is
that naive? Might I run into some unforeseen problems if I do that?
I'm a little hesitant to tweak the code, since I've been led to
believe that it was supposed to be working code before I downloaded
it. So what do you think? Should I tweak the code or should I try to
find some _other_ way to get this code working?

Kevin S
 
Reply With Quote
 
 
 
 
Ian Collins
Guest
Posts: n/a
 
      10-22-2010
On 10/23/10 11:43 AM, KevinSimonson wrote:
> I'm currently trying to use Visual Studio 2010 to build Shareaza, a
> piece of open source software that theoretically should just build
> from the C++ files without any problems. But when I attempted to
> build it I got the following two error messages:
>
> 1>c:\<path-name>\shareaza\hashlib\utility.hpp(34: error C2664:
> '_BitScanReverse' : cannot convert parameter 1 from 'uint32 *' to
> 'DWORD *'
> 1> Types pointed to are unrelated; conversion requires
> reinterpret_cast, C-style cast or function-style cast
> 1>c:\<path-name>\shareaza\hashlib\utility.hpp(370): error C2664:
> '_BitScanForward' : cannot convert parameter 1 from 'uint32 *' to
> 'DWORD *'
> 1> Types pointed to are unrelated; conversion requires
> reinterpret_cast, C-style cast or function-style cast
> 1>
> 1>Build FAILED.
>
> I took a look at the vicinity of lines 348 and 370 and got
>
> 345: inline uint32 highestBitSet(uint32 value)
> 346: {
> 347: uint32 index;
> 348: return _BitScanReverse(&index, value ) ? index : 0;
> 349: }
>
> and
>
> 367: inline uint32 lowestBitSet(uint32 value)
> 368: {
> 369: uint32 index;
> 370: return _BitScanForward(&index, value ) ? index : 0;
> 371: }
>
> and I looked<_BitScanReverse()> and<_BitScanForward()> up on the
> Internet (at "http://msdn.microsoft.com/en-us/library/fbxyd7zd%28VS.
> 80%29.aspx" and "http://msdn.microsoft.com/en-us/library/wfd9z0bb%28VS.
> 80%29.aspx") and got:
>
> unsigned char _BitScanReverse(
> unsigned long * Index,
> unsigned long Mask
> );
>
> and
>
> unsigned char _BitScanForward(
> unsigned long * Index,
> unsigned long Mask
> );
>
> In view of these definitions, can anyone tell me (1) why this code is
> generating these error messages, and (2) if it should be generating
> these error messages, why it could _ever_ have compiled on _any_ C++
> compiler. I remind you that I copied this code from an open source
> repository; theoretically this code has already been compiled to
> generate a working executable.


The code is a bit wanky, mixing fixed with types and standard integral
types is never a good idea. The relative widths of these types my vary
across platforms and there's certainly no guarantee their pointers will
be compatible. Although why the prototype parameter is "unsigned long*"
and the error says "DWORD*" is rather odd.

> I look at this code and I think, all I really have to do is change the
> type of each<index> variable from<unit32> to<unsigned long>. Is
> that naive? Might I run into some unforeseen problems if I do that?
> I'm a little hesitant to tweak the code, since I've been led to
> believe that it was supposed to be working code before I downloaded
> it. So what do you think? Should I tweak the code or should I try to
> find some _other_ way to get this code working?


Have a look and how they define "unit32" would be a good start.

--
Ian Collins
 
Reply With Quote
 
 
 
 
Geoff
Guest
Posts: n/a
 
      10-22-2010
On Sat, 23 Oct 2010 11:53:16 +1300, Ian Collins <ian->
wrote:

>On 10/23/10 11:43 AM, KevinSimonson wrote:
>> I'm currently trying to use Visual Studio 2010 to build Shareaza, a
>> piece of open source software that theoretically should just build
>> from the C++ files without any problems. But when I attempted to
>> build it I got the following two error messages:
>>
>> 1>c:\<path-name>\shareaza\hashlib\utility.hpp(34: error C2664:
>> '_BitScanReverse' : cannot convert parameter 1 from 'uint32 *' to
>> 'DWORD *'
>> 1> Types pointed to are unrelated; conversion requires
>> reinterpret_cast, C-style cast or function-style cast
>> 1>c:\<path-name>\shareaza\hashlib\utility.hpp(370): error C2664:
>> '_BitScanForward' : cannot convert parameter 1 from 'uint32 *' to
>> 'DWORD *'
>> 1> Types pointed to are unrelated; conversion requires
>> reinterpret_cast, C-style cast or function-style cast
>> 1>
>> 1>Build FAILED.
>>
>> I took a look at the vicinity of lines 348 and 370 and got
>>
>> 345: inline uint32 highestBitSet(uint32 value)
>> 346: {
>> 347: uint32 index;
>> 348: return _BitScanReverse(&index, value ) ? index : 0;
>> 349: }
>>
>> and
>>
>> 367: inline uint32 lowestBitSet(uint32 value)
>> 368: {
>> 369: uint32 index;
>> 370: return _BitScanForward(&index, value ) ? index : 0;
>> 371: }
>>
>> and I looked<_BitScanReverse()> and<_BitScanForward()> up on the
>> Internet (at "http://msdn.microsoft.com/en-us/library/fbxyd7zd%28VS.
>> 80%29.aspx" and "http://msdn.microsoft.com/en-us/library/wfd9z0bb%28VS.
>> 80%29.aspx") and got:
>>
>> unsigned char _BitScanReverse(
>> unsigned long * Index,
>> unsigned long Mask
>> );
>>
>> and
>>
>> unsigned char _BitScanForward(
>> unsigned long * Index,
>> unsigned long Mask
>> );
>>
>> In view of these definitions, can anyone tell me (1) why this code is
>> generating these error messages, and (2) if it should be generating
>> these error messages, why it could _ever_ have compiled on _any_ C++
>> compiler. I remind you that I copied this code from an open source
>> repository; theoretically this code has already been compiled to
>> generate a working executable.

>
>The code is a bit wanky, mixing fixed with types and standard integral
>types is never a good idea. The relative widths of these types my vary
>across platforms and there's certainly no guarantee their pointers will
>be compatible. Although why the prototype parameter is "unsigned long*"
>and the error says "DWORD*" is rather odd.


In Windows, DWORD is a typedef for unsigned long.

>
>> I look at this code and I think, all I really have to do is change the
>> type of each<index> variable from<unit32> to<unsigned long>. Is
>> that naive? Might I run into some unforeseen problems if I do that?
>> I'm a little hesitant to tweak the code, since I've been led to
>> believe that it was supposed to be working code before I downloaded
>> it. So what do you think? Should I tweak the code or should I try to
>> find some _other_ way to get this code working?

>
>Have a look and how they define "unit32" would be a good start.


It's uint32, not unit32 but I suspect propagation of typos here. In
boost, uint32 is typedef of uint32_t and it is a typedef for unsigned
int, thus no conversion exists for unsigned long to unsigned int.

 
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
Three supposedly cool things about D SG C++ 4 08-09-2010 03:55 PM
Call a DLL LIB function in ASP.NET (Code Behind) or VB.NET (The same code is working fine in VB 6.0) Peri ASP .Net 2 07-20-2005 03:13 AM
code completion not working in code-behind file jason ASP .Net 4 06-02-2005 04:18 PM
Arrh, something else is wrong! With almost identical code snipets to working code. David. E. Goble C Programming 9 02-02-2005 01:13 PM
Fire Code behind code AND Javascript code associated to a Button Click Event =?Utf-8?B?Q2FybG8gTWFyY2hlc29uaQ==?= ASP .Net 4 02-11-2004 07:31 AM



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