Re: How do MAKEINTRESOURCE in Euphoria?
- Posted by jimcbrown (admin) May 16, 2013
- 2078 views
This isn't correct; the primary purpose of that is to do the typecast, so that Windows can store a 16-bit integer ID in a type defined as "pointer" for convoluted reasons; Eu doesn't have types, so in Eu this macro would be a complete no-op.
My understanding was that with C, when you cast to a smaller integer type, then you lose bits. Casting back to a larger integer type does not restore the lost bits. In that case, mattlewis's code properly emulates the C behavior.
If you want to be safe, you can do an assert/check to make sure the ID is less than 0xffff, as something is wrong if it isn't. If you just mask it to 16 bits, like the code above, you'll silently corrupt the incorrect value into another incorrect value.
Agreed. Better to assert and fail early, than to do it the C way and fail bizarrely.