[futurebasic] Re: [FB] FBtoC Conversion

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : February 2008 : Group Archive : Group : All Groups

From: Robert Purves <listrp@...>
Date: Fri, 15 Feb 2008 10:38:30 +1300
Peter wrote:

> long if mHndl and ( nItems > 0 )
> end if

FBtoC emits illegal C code:
	if (mHndl & ( (-(nItems > 0 )) ) ) { ... };
Clearly that's a bug, and I've made a new entry in our database.

----------------------------
326	Won't fix	Error	gcc error from Boolean expression with pointer/ 
Handle
dim as Handle h
dim as Boolean b
b = h and ( 1 > 0 ) // invalid operands to binary &
// workarounds:
b = (h) and ( 1 > 0 )
b = ( h != 0 and 1 > 0 )
----------------------------


I marked the bug as 'Won't fix' for two reasons.
(a) It would be extremely hard for us to fix.
An idiomatic manual translation would certainly use the logical  
operator &&:
   if ( mHndl && ( nItems > 0 ) ) { ... };
In FB the 'and' operator is binary, which FBtoC emits as the binary  
'&' in C. Currently FB has no logical 'and'. The FB && operator is a  
synonym for binary 'and'.

(b) The workarounds suggested by Michele and Bernie, as shown in the  
bug entry, are easy.

Robert P.