Hi,

On Mon, 25 Sep 2000, R. Lahaye wrote:

>Hello,
>
>In  src/uipp/dxuilib/EditorWindow.C  line 4367:
>
>   int xmin=1e6,xmax=0,ymin=1e6,ymax=0;
>
>something is obviously wrong here. Either  int -> float, or  1e6 -> 1000000
>I can't see which of the two changes is best. I suppose an expert out there
>will know :).


While this might look strange, it should work just fine.  
It's equivalent to

int xmin=(int)1e6, xmax=0, ymin=(int)1e6, ymax=0;
 
>Similar problems in same file:
>
>(line 4361)  int begx, begy;
>             int endx, endy;
>
>(line 4421)  begx = (x_pagesize * border_percent) * 72;
>             begy = (y_pagesize * border_percent) * 72;
>             endx = (x_pagesize * 72) - begx;
>             endy = (y_pagesize * 72) - begy;
>
>because x/y_pagesize and border_percent are floats.
>Probably the assignments should become
>
>             begx = int(x_pagesize * border_percent) * 72;
>             etc.
>         or
>             begx = int(x_pagesize * border_percent * 72);
>             etc.
>     and/or
>             use int(ceil( )) instead of simply int(). 
>
>     ( the latter needs also  #include <math.h> )

Again I think this should work just fine.  If you want to add a type cast
before the assignment then just add (int).  Since type casting has higher
precedence than multiplication (and therefore addition and subtraction)
this will result in the multiplication in parentheses done first, then a
type cast, then the multiplication by 72 or subtraction of begx or begy.

 begx = (int)(x_pagesize * border_percent) * 72;
 begy = (int)(y_pagesize * border_percent) * 72;   
 endx = (int)(x_pagesize * 72) - begx;
 endy = (int)(y_pagesize * 72) - begy;

>In src/uipp/dxuilib/DXApplication.C  lines 165 to 169 assigns the NULL
>pointer, which seems to be confusing for my compiler (is a cast necessary 
>here?):
>
>DXApplication.C:165: warning: initialization to `Symbol' from `{unknown type} 
>*'
>lacks a cast
... snip ...

As for these errors I'd look for another type of bug.  You can assign any
pointer to NULL.  For most compilers NULL is macro expanded to ((void *)0)
and any pointer can be assigned to a void type pointer.  If you're using
gcc then you can try to use the flag -E or -M, I can't remember which one
exactly, but it will result in the output of the preprocessor being sent
to stdout which you can redirect to less or a file or something like that.
You should see the NULL replaced with ((void *)0) ...

Hope this helps,

Tom

Reply via email to