Translator Issues
- Posted by Greg Haberek <g.haberek at comcast.net> Feb 27, 2003
- 448 views
I'm getting an error when I translate the following code to C. (code is from Jordah Ferguson's binary.e) since I'm not fluent in C, I need a little help with this. is it a problem with Euphoria, C, or the Translator? please note: 'first' is not used *anywhere* in my Euphoria code from binary.err: binary.c(25): Error! E1031: Name 'first' not found in struct/union s1 -- begin eu code -- type string(sequence s) for i = 1 to length(s) do x = s[i] if integer(x) then if x < 0 or x > #FF then return 0 end if else return 0 end if end for return 1 end type -- end eu code -- /* begin c code */ int _0string(int _s) { int _32 = 0; int _27 = 0; int _26; int _0, _1, _2, _3; // for i = 1 to length(s) do _26 = SEQ_PTR(_s)->length; { int _i; _i = 1; L0: if (_i > _26) goto L1; // x = s[i] DeRef(_0x); _1 = _i - 1; _2 = (int)SEQ_PTR(_s); _0x = (int)*(_1 + ((s1_ptr)_2)->first); // herein lies the error, 'first' not defined Ref(_0x); // if integer(x) then DeRef(_27); if (IS_ATOM_INT(_0x)) _27 = 1; else if (IS_ATOM_DBL(_0x)) _27 = IS_ATOM_INT(DoubleToInt(_0x)); else _27 = 0; if (_27 == 0) goto L2; // if x < 0 or x > #FF then if (IS_ATOM_INT(_0x)) { _27 = (_0x < 0); } else { _27 = binary_op(LESS, _0x, 0); } if (IS_ATOM_INT(_27)) { if (_27 != 0) { goto L3; } } else { if (DBL_PTR(_27)->dbl != 0.0) { goto L3; } } DeRef(_32); if (IS_ATOM_INT(_0x)) { _32 = (_0x > 255); } else { _32 = binary_op(GREATER, _0x, 255); } L4: if (_32 == 0) goto L5; else if (!IS_ATOM_INT(_32) && DBL_PTR(_32)->dbl == 0.0) goto L5; L3: // return 0 DeRefDS(_s); DeRef(_32); DeRef(_27); return 0; L6: goto L5; L2: // return 0 DeRefDS(_s); DeRef(_32); DeRef(_27); return 0; L5: // end for _i = _i + 1; goto L0; L1: ; } // return 1 DeRefDS(_s); DeRef(_32); DeRef(_27); return 1; ; } /* end c code */ thanks, ~Greg g.haberek at comcast.net