Private constants in Eu 4.0
- Posted by RStowasser Jan 18, 2009
- 924 views
I would like to point to a problem using privat constants with Eu 4.0 (rev 1339)
when using Eu 4.0 almost no example of the EuGtk2 examples will run with Windows (Vista). As an example I use arrow.exw:
C:\EUPHORIA\include\gtk2/hbox.gtk:45 in function hbox()
A machine-level exception occurred during execution of this statement
... called from D:\Euphoria\gtk2Win\demos\arrow.exw:14
I changed the code of hbox.gtk a little bit and commented out the original code:
... constant new = define_c_func(GTK, "gtk_hbox_new", {B, I}, P) ----------------------------- -- hbox() ----------------------------- global function hbox(boolean homogeneous, integer spacing) ----------------------------- -- return newInstance(c_func(new, {homogeneous, spacing})) atom ret ? new ret = c_func(new, {homogeneous, spacing} ) ? ret ret = newInstance(ret) ? ret return ret end function -- hbox() ...
Now I got this error:
C:\EUPHORIA\include\gtk2/hbox.gtk:47 in function hbox()
A machine-level exception occurred during execution of this statement
... called from D:\Euphoria\gtk2Win\demos\arrow.exw:14
> See ex.err
Press Enter...
The error happens when new should be printed. Why does this not work? new had been already defined.
I think there are several places with IDE using the int type where the same problem happens. Although I changed almost all symbols int to integer I forgot some in FList.ew. Using this code in FList.ew:
... -- Flag set/clear/test routine -- This has not worked out as well as I'd have liked ... I like macro capability function TestFlag(integer var, integer bit) return and_bits(var, bit) end function function SetFlag(integer var, int bit) ? var ? bit return or_bits(var, bit) end function function ClearFlag(integer var, integer bit) return and_bits(var, not_bits(bit)) end function ...
will produce this error with me when running IDE:
1
D:\Euphoria\IDE105\FList.ew:269 in function SetFlag()
A machine-level exception occurred during execution of this statement
... called from D:\Euphoria\IDE105\FList.ew:1052 in function FList()
... called from D:\Euphoria\IDE105\includes\ide_code.ew:1670
> See ex.err
Press Enter...
line 1052 in function in my Flist.ew shows this:
Dummy[D_FLFlags] = SetFlag(Dummy[D_FLFlags], FL_Enable)
Dummy[D_FLFlags] = integer is printed (1), FL_Enable = int crashes
D_FLFlags and FL_Enable are declared as constants somewhere about line 175 in FList.ew.
What is the difference if I use constants with integer instead of type int?
Roland