[M3devel] how to write constants?

Jay K jay.krell at cornell.edu
Mon Sep 2 00:51:35 CEST 2013


 > I presume you mean so it works on both 32-bit and 64-bit?
There should be no doubt that almost everything should.
Yes.

> > VS_FFI_SIGNATURE    : INT32 = -17890115; (* 16_FEEF04BD *)
> >
> 
> Works, but tedious to hand-compute and to double-check consistency with
> the comment.  How about 16_FEEF04BD-16FFFFFFFF-1?

I can try that.
I couldn't hand compute it.
I gave up and used a reliable calculator:
#include <stdio.h>
int main() { printf("%d\n", 0xFEEF04BD); return 0; }

but yeah, something obviously correct by inspection would be nice.

Notice that I can't use Word or Long to help compute such constants.
I kinda think we need a Word32 interface (and Long should then have been called Word64).


> Does it seem odd that numbers like this in the upper-half unsigned range
> are being given to a signed type?


Sure, but, maybe I'm confused, but we don't have this upper-half in our unsigned types either.
I can try foo: UINT32 = 16_FFFFFFFF or 16_FEEF04BD or such.


We also had I think negative numbers assigned to unsigned types.


 - Jay


> Date: Sun, 1 Sep 2013 16:54:22 -0500
> From: rodney_bates at lcwb.coop
> To: m3devel at elegosoft.com
> Subject: Re: [M3devel] how to write constants?
> 
> 
> 
> On 08/31/2013 01:17 AM, Jay K wrote:
> > What is the right way to do this for 64bit systems?
> 
> I presume you mean so it works on both 32-bit and 64-but?
> 
> >
> >    other       : INT32 = 16_FFFFFFFF;
> >
> >
> > "../src/win32/WinUser.i3", line 1321: warning: value not assignable (range fault)
> >    WS_POPUP       : INT32 = 16_80000000;
> >
> > "../src/win32/WinVer.i3", line 37: warning: value not assignable (range fault)
> >    VS_FFI_SIGNATURE    : INT32 = 16_FEEF04BD;
> >
> >
> > I'm guessing..
> >   other : INT32 := -1;
> 
> Yes, assuming this is the same INT32 as the other two cases (a subrange
> covering 32-bit signed twos-complement.  (I couldn't find this declaration,
> thus nor its INT32 type.)
> 
> > WS_POPUP = FIRST(INT32)
> 
> That will work.  Ultimately, the buck has to stop being passed, and
> following more levels of transitive type renaming than I want to count,
> I see the type defined as [-16_7fffffff-1 .. 16_7fffffff], whose lower
> bound is the way I would have done it as a ground constant.
> 
> I see two different BasicCTypes.i3 versions, inside subdirectories
> 32BITS and 64BITS, but this decl is the same in both.
> 
> > VS_FFI_SIGNATURE    : INT32 = -17890115; (* 16_FEEF04BD *)
> >
> 
> Works, but tedious to hand-compute and to double-check consistency with
> the comment.  How about 16_FEEF04BD-16FFFFFFFF-1?
> 
> Does it seem odd that numbers like this in the upper-half unsigned range
> are being given to a signed type?
> 
> >
> > ?
> >
> >   - Jay
> 
 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://m3lists.elegosoft.com/pipermail/m3devel/attachments/20130901/f7447ee4/attachment-0002.html>


More information about the M3devel mailing list