[omniORB] const unsigned long 0xffffffff
Gary D. Duzan
gdd0@gte.com
Mon, 06 Apr 1998 12:28:43 -0400
In Message <3528C643.DBD4126F@access.bel.alcatel.be> ,
Melih Ercan xe44 9777 <ercanm@access.bel.alcatel.be> wrote:
=>When I define the following in IDL:
=>
=>const unsigned long myConst=0xffffffff;
=>
=>I got the following error msg from the IDL compiler:
=>
=>omniidl2: "tank.idl", line 1: coercion failure -1 to unsigned long
=>omniidl2: tank.idl: found 1 error
=>
=>It is obvious that the constant 0xffffffff is seen as signed (i.e. -1).
=>So I will get an error
=>message for all constants greater than 0x80000000. Is there a way to say
=>that 0xffffffff
=>is unsigned?
=>
=>Regards.
=>
=>Melih Ercan.
That's a very good question. Here is what CORBA 2.1 section 3.7.2
says about the matter (I don't have 2.0 handy):
If the type of an integer constant is long or unsigned long, then
each subexpression of the associated constant expression is
treated as an unsigned long by default, or a signed long for
negated literals or negative integer constants. It is an error if
any subexpression values exceed the precision of the assigned
type (long or unsigned long), or if a final expression value (of
type unsigned long) exceeds the precision of the target type
(long).
So while it may make parsing a bit messy (i.e. context sensitive),
it seems that IDL should provide what you want by default. So this
would point to an OmniIDL bug, unless, of course, this is another
change from 2.0.
Gary Duzan
GTE Laboratories