tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] Can't compile the eiffel generated C files


From: Daniel Gryniewicz
Subject: Re: [Tinycc-devel] Can't compile the eiffel generated C files
Date: Thu, 28 Jul 2005 17:22:10 -0400

On Thu, 2005-07-28 at 17:29 -0400, Dave Dodge wrote:
> > arachno_ruby156.c:679: cannot use pointers here
> 
> It looks like a SmartEiffel problem.  Here's the line of code:
> 
>   R=(((T6)((/*RF2*/(((T382*)C))->_second/*4*/))))
> 
> "R" is a char.  "T6" is type char. "_second" is a struct pointer.
> It's casting a struct pointer value to a char value.  That is at best
> implementation-defined and at worst undefined.  It's basically the
> same as:
> 
>   struct foo * x;
>   char y = (char)x;
> 
> Which is obviously non-portable C code.  gcc will complain about it if
> you turn up the warning level:
> 
>   arachno_ruby156.c:679: warning: cast from pointer to integer of different 
> size
>   arachno_ruby156.c:685: warning: cast from pointer to integer of different 
> size

Worse than this, I believe gcc 4.0 will fail to compile this with an
error.

> > arachno_ruby119.c:2347: cannot cast 'struct S1763 *' to 'struct S0 *'
> 
> It looks like a SmartEiffel problem.  Here's the statement:
> 
>   call_e2r0e6v(&ds,vc(a2,1017183770),_b,C,1);
> 
> T0 is struct {int id; }
> T1763 is struct {int id; plus some other stuff }
> C is a pointer to a T1763.
> The function expects a pointer to a T0.
> 
> This requires a cast.  For example:
> 
>   call_e2r0e6v(&ds,vc(a2,1017183770),_b,(T0*)C,1);
> 
> When a function is called using a prototype, the implicit argument
> conversions are done with the same rules as assignment.  An assignment
> of a structure pointer requires that the structures be compatible.
> Structure compatibility requires all fields to match.  This is
> essentially the same problem as:
> 
>   struct x { int a; };
>   struct y { int a; int b; };
> 
>   struct x foo;
>   struct y * bar;
>   bar = &foo;        /* cast needed */
> 
> Again, gcc will tell you there is a problem if you turn up the warnings:
> 
>   arachno_ruby119.c:2347: warning: passing arg 4 of `call_e2r0e6v' from 
> incompatible pointer type

And again, I believe gcc 4 will error.

Daniel





reply via email to

[Prev in Thread] Current Thread [Next in Thread]