Re: Phix: 64bit (-1) equal #ffffffffffffffff ?!

new topic     » goto parent     » topic index » view thread      » older message » newer message
andreasWagner said...

should open a serial port and return the handle or INVALID_HANDLE_VALUE(-1) if it fails

C:\TDM-GCC-64\x86_64-w64-mingw32\include>grep -i INVALID_HANDLE_VALUE *.* 
pdh.h:#define INVALID_HANDLE_VALUE ((HANDLE)((LONG_PTR)-1)) 
handleapi.h:#define INVALID_HANDLE_VALUE ((HANDLE) (LONG_PTR)-1) 
This works nice with Phix 32bit:

But works not so nice with Phix 64bit:
If it fails,the function returns #ffffffffffffffff instead of (-1), isn't it the same?
The result on my Computer:

18446744073709551615 
1111111111111111111111111111111111111111111111111111111111111111 
1111111111111111111111111111111111111111111111111111111111111111 
 
18446744073709551615 
1111111111111111111111111111111111111111111111111111111111111111 
1111111111111111111111111111111111111111111111111111111111111111 
 
152 
10011000 
1111111111111111111111111111111111111111111111111111111111111111 
 
156 
10011100 
1111111111111111111111111111111111111111111111111111111111111111 
 
18446744073709551615 
1111111111111111111111111111111111111111111111111111111111111111 
1111111111111111111111111111111111111111111111111111111111111111 
 
18446744073709551615 
1111111111111111111111111111111111111111111111111111111111111111 
1111111111111111111111111111111111111111111111111111111111111111 
 
{"COM5:","COM6:","COM7:","COM8:","COM9:","COM10:"} 

Maybe someone can enlighten me.

Not sure, but seems like it's returning a 32bit int sometimes rather than the 64bit long that's needed to get to -1 on a 64bit system. (This bug is not noticible on 32bits since sizeof(long) == sizeof(int) == 32bits, but on 64bit intel/amd systems sizeof(long) is twice sizeof(int) and this was a major headache in getting OE ported to 64bits due to all the assumptions made between sizeof(void*) and sizeof(long) and sizeof(int).)

andreasWagner said...

Maybe I should just continue with 32bit. For my small programs there is not really a need to support 64bit.

Of course, no harm in sticking to what works or what you need.

andreasWagner said...

This is not the first time I have come across such oddities. I just forgot about it.
Andreas

Thanks for reporting it though - even if there's no immediate response, having the report can be helpful to someone else in realizing that a bug exists and in figuring out the issue and solving it.

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu