On Thu, Mar 12, 2009 at 8:25 PM, Eduardo Cavazos <[email protected]> wrote:
>> extern Status XQueryTree(
>> Window** /* children_return */,
>> );
>> (c-function Status XQueryTree (... (c-pointer (c-pointer unsigned-long)) ...)
>> I can allocate enough storage for a pointer via:
>> (define children-return (allocate sizeof:c-pointer))
>> The trouble is, how do I portably extract the address?
(let-location ((children-return (c-pointer unsigned-long)))
(XQueryTree ... (location children-return) ...)
(pointer-u32-ref children-return)) ; obtain window
Test example below. But consider, on a 64-bit machine, will an
unsigned long (Window) still be 32 bits?
#>
unsigned long buf[] = { 0xdeadbeefL };
void foo(unsigned long **ret) { *ret = buf; }
<#
(define foo (foreign-lambda void "foo"
(c-pointer (c-pointer unsigned-long))))
(let-location ((ptr (c-pointer unsigned-long)))
(foo (location ptr))
(printf "0x~x\n" (pointer-u32-ref ptr))) ; 0xdeadbeef
_______________________________________________
Chicken-users mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/chicken-users