Hi Jiri, You are right. There is a problem with byte swapping and bool. I can reproduce the same problem under HP-UX. Masa, I assume that you will fix this problem. Rene Brun Jiri Masik wrote: > > "Stephen J. Sanders" <ssanders@ku.edu> writes: > > > Hi Jiri and Damir, > > Thanks for the input. It looks like this is a problem that may solve itself > > with a little patience. If Debian is running gcc 3.0.4 my guess is > > the other > > distributions won't be too far behind. In the meantime, I can either > > avoid the > > use of booleans or fall back for root 3.02/07, which doesn't have this > > problem. > > > > Regards, > > Steve > > > > Hi, > > unfortunately an upgrade of gcc won't solve this completely. As Damir > mentioned there's another problem with booleans - the following > code > int main(void){ > bool a; > a=true; printf("%d\n",a); > a=false; printf("%d\n",a); > a=true; printf("%d\n",a); > > return (0); > } > > prints just 0's on my PPC. It looks like assignment to a bool > variable works only in the declaration. > > I'm trying to find out where the value of a bool is lost. > It might be related to the lines of cint/src/var.c > > #define G__GET_VAR(SIZE,CASTTYPE,CONVFUNC,TYPE,PTYPE) \ > switch(G__var_type) { \ > case 'p': /* return value */ \ > if(var->paran[ig15]<=paran) { \ > /* if(var->varlabel[ig15][paran+1]==0) { */ \ > /* value , an integer */ \ > result.ref = (G__struct_offset+var->p[ig15]+p_inc*SIZE); \ > CONVFUNC(&result,TYPE,(CASTTYPE)(*(CASTTYPE *)(result.ref)));\ > } \ > > result.ref is a long and for a boolean variable it is called as > G__GET_VAR(G__INTALLOC ,unsigned char ,G__letint ,'g' ,'G') > > so there's a cast like (unsigned char)(*(unsigned char *)(long)) > > Is this cast guaranteed to work for both little and big endian > systems? On PPC the function G__letint is called with 0 for result.ref > being either 1 or 0 as the cast is done on the insignificant byte I > guess. > > cheers > Jiri
This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:52 MET