[gambit-list] use of cast expressions as lvalues

Marc Feeley feeley at iro.umontreal.ca
Sun Jan 29 15:00:29 EST 2006


On 29-Jan-06, at 9:56 AM, Christian wrote:

> Hello
>
> Speaking of compiler warnings: I'm sometimes getting:
>
> foo.c:7033: Warnung: use of cast expressions as lvalues is deprecated
>
> in cases like:
>
> (c-declare ".......
>             struct sigqueue * global_queue;")
> ....
> (define global-queue (c-lambda () sigqueue "___result=  
> global_queue;"))
>
> Is there a more correct way to assign something to the result?

Yes.  Whenever you are returning a pointer, you have to assign it to  
___result_voidstar (which is a variable of type void*).  So your code  
should read:

(define global-queue (c-lambda () sigqueue "___result_voidstar =  
global_queue;"))

Gambit uses this approach to avoid some problems with C++ handling of  
pointers.

Marc




More information about the Gambit-list mailing list